Design a High-Card Game with a Persistent Tie Pot
Company: Affirm
Role: Software Engineer
Category: Software Engineering Fundamentals
Difficulty: easy
Interview Round: Technical Screen
# Design a High-Card Game with a Persistent Tie Pot
Model and implement a card game. A shuffled deck is split evenly among two players. In each round, every active player reveals the top card of their personal deck. A unique highest rank wins all cards currently in the pot. If the highest rank is tied, the revealed cards remain in the pot and another round is played. Begin with two players, then explain how the model and round logic extend to `N` players.
Focus on classes, ownership of cards, deterministic testing, tie handling, and termination. State a policy for players who cannot contribute a card while a tie pot is unresolved; pseudocode is acceptable.
### Constraints & Assumptions
- Suits do not affect comparison; ranks have a total order.
- A card is in exactly one place: draw pile, current reveal, pot, or won pile.
- Shuffling is injected or seeded for deterministic tests.
- Because repeated play can cycle under some collection policies, define a maximum-round or repeated-state rule.
### Clarifying Questions to Ask
- Does a winner place captured cards in a separate score pile or back into a draw pile?
- When only some players tie for highest rank, do all players enter the next tie-breaking round?
- What happens if a tied player runs out of cards?
- Is the winner determined by captured-card count, last active player, or another condition?
### What a Strong Answer Covers
- Clear card ownership and round-state invariants
- Separation among deck construction, shuffling, dealing, rules, and game orchestration
- A tie-pot state machine that works for more than two players
- Explicit termination and exhausted-player semantics
- Tests that do not depend on random shuffle output
### Follow-up Questions
- How would you serialize and resume a game in progress?
- Which rule changes should require a new class rather than a conditional?
- How do you prove no card is lost or duplicated?
- What changes if captured cards return to the player's draw pile?
Quick Answer: Design a high-card game in which tied rounds carry a persistent pot into later rounds, first for two players and then for many. Define card ownership, tie and exhaustion policies, deterministic shuffling, termination rules, extensible classes, and tests for tricky state transitions.