PracHub
QuestionsCoachesLearningGuidesInterview Prep

Quick Overview

This question evaluates algorithmic problem-solving in combinatorial search, state-space optimization, and memoization by asking for the maximum achievable score in a constrained card-removal game; it falls under the Coding & Algorithms domain, specifically combinatorics, search, and dynamic programming.

  • medium
  • Meta
  • Coding & Algorithms
  • Software Engineer

Maximize score in 15-sum card game

Company: Meta

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Onsite

## Problem A deck has **36 cards**: 4 suits × ranks 1 through 9 (so there are exactly four `1`s, four `2`s, …, four `9`s). Suits do not affect scoring; only ranks matter. A game proceeds as follows: 1. The deck is shuffled into a fixed order. The first **16 cards** are dealt face-up onto the table (the “board”). The remaining cards stay in the draw pile. 2. While possible, you may repeatedly: - Choose **three cards currently on the board** whose ranks sum to **15**. - Remove those three cards and gain **15 points**. - Draw cards from the draw pile to restore the board back to **16 cards** (draw exactly 3 if available; otherwise draw as many as remain). 3. The game ends when either: - The draw pile is empty and no further 15-sum triple exists on the board, or - No 15-sum triple exists on the board (even if cards remain in the pile, you cannot draw unless you remove a triple). The theoretical maximum score is `180` (12 triples × 15 points) because there are 36 cards. ### Task Given the full shuffled deck order, compute the **maximum total score** achievable by choosing triples optimally. ### Input - A list `deck` of length 36. Each element is an integer rank in `[1..9]`. - The multiset of ranks in `deck` satisfies: each rank 1..9 appears exactly 4 times. ### Output - An integer: the maximum score achievable. ### Examples (illustrative) - If the initial 16-card board contains no triple summing to 15, output is `0`. - If an optimal play can remove 12 triples, output is `180`. ### Follow-ups (if time) 1. Implement a baseline greedy strategy (e.g., pick any available 15-sum triple). 2. Write a test that runs the game for 100 random shuffles and reports how often the strategy achieves 180. ### Constraints - Deck size is fixed (36), but the branching factor can be high; design an approach that avoids exponential blow-ups where possible (e.g., memoization).

Quick Answer: This question evaluates algorithmic problem-solving in combinatorial search, state-space optimization, and memoization by asking for the maximum achievable score in a constrained card-removal game; it falls under the Coding & Algorithms domain, specifically combinatorics, search, and dynamic programming.

A deck has card values. Deal 16 cards, then repeatedly remove triples summing to 15 or draw the next card. Return the maximum number of triples removable.

Constraints

  • Inputs are provided as Python literals compatible with the function signature.
  • Return a deterministic value exactly matching the requested output.

Examples

Input: ([1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9],)

Expected Output: 12

Explanation: Sorted valid deck.

Input: ([1, 5, 9, 2, 4, 9, 3, 5, 7, 6, 7, 2, 8, 1, 6, 3, 4, 8, 9, 5, 1, 7, 2, 6, 3, 8, 4, 9, 5, 1, 7, 2, 6, 3, 8, 4],)

Expected Output: 12

Explanation: Shuffled valid deck.

Hints

  1. Start with a direct data structure representation.
  2. Handle edge cases before the main loop.
Last updated: Jun 27, 2026

Loading coding console...

PracHub

Master your tech interviews with 8,000+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • AI Coding Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.

Related Coding Questions

  • Find Shortest Unique Prefixes - Meta (medium)
  • Compute Exclusive Execution Times - Meta (medium)
  • Solve Tree Columns And Maze Variants - Meta (medium)
  • Solve Tree Diameter and Palindromic Counts - Meta (medium)
  • Simulate Monster Team Battles - Meta (hard)