Affirm: Card game simulation that scales from two players to N
Problem. Shuffle a standard 52-card deck and split it into piles, one per player. Each round, players compare their top cards; the player with the higher card takes both and sets them aside. When the piles run out, the player with the most cards wins. Output the winner.
Follow-ups.
- Extend from two players to N players.
- Decide how to deal when 52 does not divide evenly among N players.
Format. You define your own classes and methods, and provided test cases are run against them.
What mattered. The candidate said the logic was easy but they failed, partly from forgetting the exact rules. Clean classes for deck, player and game, clear tie handling and a design that does not hard-code two players are what make the follow-up smooth.
Comments 0
No comments yet. Ask the author something, or add what happened in your own round.