Learn AI Coding
mediumStructured · sandbox50 min

Card Game

Manage a deck and simulate a trick-taking hand, data structure design and simulation with a bug → feature → scale arc.

Data Structures

Problem

A card game engine manages a 52-card deck and simulates trick-taking rounds. The starter code has a bug.

Phase 1: Fix the bug

shuffle() is broken: it can leave the deck with duplicate cards or miss cards entirely. The deck must contain each card exactly once after shuffling.

Phase 2: Feature

Implement a full trick: each player plays one card; the highest card of the lead suit wins, unless a trump is played, in which case the highest trump wins. Track who takes each trick.

Phase 3: Scale

The game grows to many players across many rounds. Deck state and trick resolution must not drift or slow down.

What interviewers watch

A correct swap-based shuffle, clean per-trick state (not shared mutable leftovers), and review of the trump resolution logic the AI produces.