Microsoft Interview Problem #2 — Card Game Simulation

23 Views
No Comments

Design a simulation for a card game. This game is playable by 2 or more players
and consists of four phases performed in order: shuffle, deal, exchange, and score.

  • shuffle: randomize the order of a deck of 52 playing cards
  • deal: from the top of the deck, give each player 5 cards
  • exchange: each player may discard as many cards (face down) as they would like.
    After they have discarded their cards, draw from the top of the deck
    until the player has 5 cards in their hand.
  • score: determine which player has the highest numerical value of cards in their hand
    (face cards are worth 10 points each). If exactly one player has the highest
    combined value, then that player is declared the winner of the game.

Deck of cards:

  • 13 cards per suit: A, 2, 3, 4, 5, 6, 7, 8, 9, 10, J, Q, K
  • 4 suits: HEARTS, DIAMONDS, CLUBS, SPADES
  1. Represent each card as (value, suit).
  2. Create the full deck of 52 cards.
  3. Shuffle using random.shuffle().
  4. Give each player 5 cards.
  5. For each player:
    • Ask which cards to discard
    • Draw new cards until hand size = 5
  6. Scoring:
    • Convert card face to score
    • Compute total for each player
    • Determine winner

The VOprep team has long accompanied candidates through various major company OAs and VOs, including Microsoft Google, Amazon, Citadel, SIG, providing real-time voice assistance, remote practice, and interview pacing reminders to help you stay smooth during critical moments. If you are preparing for Stripe or similar engineering-focused companies, you can check out our customized support plans—from coding interviews to system design, we offer full guidance to help you succeed.

END
 0