AI Interviews · Question

AI coding round: implement a card game with card and player classes, shuffling and dealing. The interviewer still wanted you to write the implementation; the candidate used the AI as a reviewer for readability and missing test cases.

AI-assisted coding question reported at Meta (2026). Sources, confidence and an answer card.

Researched · updated

r2a-007 Both tracks AI-assisted coding rounds AI-assisted coding Senior Medium confidence
On this page

What they’re really asking

If you only remember one thing, say this in the first minute: “First I’ll ask how you’d like me to use the assistant here. Then I’ll sketch four small classes, Card, Deck, Player and Game, with the rules in one place and the random source passed in so tests are repeatable. I’ll write them myself, with a fair Fisher–Yates shuffle, and use the assistant as a reviewer: I’ll ask it what edge cases and tests I’m missing, and I’ll say which suggestions I accept and why I reject the others.”

The rest of this page explains each part of that answer.

This is object design that you own, with the assistant in a supporting role.

Most AI-assisted rounds reward letting the assistant type. This report shows the opposite case. The assistant is a chat tool backed by a large language model (LLM), a program trained on huge amounts of text and code that writes a plausible reply to what you type. Used as a reviewer, it reads your code and suggests missing tests, unclear names and edge cases. Some suggestions are good, some are noise. The skill on show is judging them, the same as judging comments from a human reviewer on a pull request.

A Meta Senior Software Engineer (Infrastructure, L5) candidate describes implementing a card game with card and player classes, shuffling and dealing. The interviewer still wanted the candidate to write the implementation, and the candidate used the AI as a reviewer for readability and missing test cases (Aced (formerly Exponent)first-hand · 2026). Expect the interviewer’s preference to vary; this round rewards reading it early and adapting.

Clarify first

  • How the interviewer wants the AI used. Writing code, or reviewing it? Ask directly: “Would you like me to write this myself and use the assistant to review?”
  • The game’s rules. Number of players, cards per hand, turn order, how a round is won, what ends the game.
  • What may change next. New rules, more players, a different deck? That decides where the class boundaries go.
  • Deterministic tests. May I pass in the random source, so a test can fix the shuffle?

Answer

Words you need first

  • Value object: a small object defined only by its fields, such as a card’s rank and suit. Two cards with the same fields are equal.
  • Injecting the random source: passing the random number generator into shuffle instead of creating it inside. A test can then pass a generator with a fixed seed (starting value), so the shuffle comes out the same every run.
  • Fisher–Yates shuffle: the standard fair shuffle. For each position from the end of the deck down to the second card, swap it with a random position at or before it.

Design first, in two minutes

Game ── owns turn order and the rules (one method: play_turn)
 ├── Deck ── list of Card; shuffle(rng); deal(n)
 │     └── Card ── rank, suit (value object)
 └── Player ── name, hand (list of Card)

Keep the rules behind one method, so a rule change touches one place. Pass the random source in, so tests are deterministic. Say why: “If you add a rule next, it goes in play_turn and nothing else changes.”

Write it yourself, quickly

If the interviewer wants your code, type the classes yourself; they are short. Shuffle with Fisher–Yates: for i from the end down to 1, swap with a random index in [0, i]. Swapping with a random index across the whole deck is a well-known biased version: it looks almost the same and makes some orders more likely than others. Dealing should fail clearly when the deck runs out.

Say it like this: “I swap with an index up to i, not across the whole deck. The whole-deck version is biased.”

The arithmetic behind the numbers (for a Staff-level follow-up)
  • Three cards, biased version: each of the 3 positions swaps with any of 3 positions, so there are 3 × 3 × 3 = 27 equally likely sequences of swaps. There are only 3 × 2 × 1 = 6 possible orders of the deck. 27 doesn’t divide evenly by 6, so some orders must come up more often than others.
  • Three cards, Fisher–Yates: the first swap has 3 choices, the next has 2, the last has 1: 3 × 2 × 1 = 6 sequences, one per order. Every order is equally likely.

The worked example: one review round with the assistant

Paste the Deck class and ask specific questions: “What edge cases does this miss? What tests would you add? Is any name unclear?” Treat the answers as suggestions to evaluate, not changes to apply. A plausible review, and what to do with each point:

The assistant suggestsYour callWhat to say in the interview
”deal doesn’t handle an empty deck.”accept”Good catch. It should raise a clear error; I’ll add a test."
"After a reshuffle of the discard pile, cards could be duplicated.”accept, add a test”Every card should be in exactly one place. I’ll assert that."
"A player with no cards may still be given a turn.”check the rules”Depends on the rules. Let me check the spec before I change it."
"Rename deal to distribute_cards.”reject”deal is the domain word; the longer name adds nothing."
"Add an abstract base class for card games.”reject”We have one game. I’ll add the abstraction when there’s a second.”

The first three are the typical useful catches: dealing from an empty deck, duplicate cards after a reshuffle, a player with no cards on their turn. Accept the ones you agree with, and say why you reject the others. Rejecting a suggestion with a reason is as much a signal as accepting one.

Tests

  • A seeded shuffle gives a known order.
  • A full deal leaves the deck empty, with every card in exactly one hand.
  • The game ends under the stated rule.
  • If time allows, a statistical sanity check on the shuffle: over many seeded runs, each card lands in each position roughly equally often.

Senior vs Staff

Card game with an AI reviewer

Senior

  • Writes clean classes quickly, uses an unbiased shuffle, and turns the AI's review into specific tests.

Staff

  • Chooses boundaries for the likely next rule change and explains which review suggestions were rejected and why.

Small-team version

“AI as first-pass reviewer” is a cheap, low-risk use on a small team. An agent (an AI assistant that can read the repo and act on its own) comments on every pull request about missing tests, unclear names and edge cases, and a person decides.

  • It’s already practised. A two-person team at Every describes this setup: an agent does first-pass code review and humans keep the final review (Every, 2025-06-11; self-reported).
  • The risk is review fatigue. Noisy comments train people to ignore all of them, including the good ones. Tune the instructions, or limit the reviewer to tests and edge cases.
  • The money is small; the attention is not. A review bot costs little next to an engineer’s time. The real cost is each comment a person has to read and dismiss, so measure how many get accepted.

Pitfalls

  • Assuming the AI must write the code. This interviewer wanted the candidate’s own code; ask first.
  • A biased shuffle. Swapping across the whole deck makes some orders more likely.
  • Applying every review suggestion without judging it. A reviewer, human or AI, is sometimes wrong.
  • Untestable randomness. Without an injected seed, no test can check a specific shuffle.

Go deeper

Family

AI-assisted coding round in a provided codebase

Meta-style rounds (and their Microsoft, OpenAI, Apple and Fireworks cousins): fix a bug, build a feature and make it faster in a repo you've never seen, with an AI assistant you direct, check and sometimes overrule.

Other questions in this family