Free preview

Why this matters: the chess move validator is a requirements trap wearing a familiar game as camouflage. Everyone knows how the pieces move, so candidates assume the requirements are obvious and skip to code — and in doing so, most of them silently define "legal" wrong. One question, asked or unasked in the first five minutes, splits the field for the entire round.

The prompt, as given

Design the move-validation core of a chess application.

Given a position and a proposed move, your module decides whether the move is legal. No engine, no AI, no searching for good moves — validation only. A UI team will sit on top of you and take your verdicts as truth.

Chess has more rules than people remember, and some of them are famously awkward for clean code. How much of that you take on now versus later is part of the design conversation.

Read that last paragraph again — the prompt is telling you that scope is negotiable and that you should negotiate it. Few prompts are this generous, and interviewers notice who takes the hint.

The question that separates candidates

"What does 'legal' fully mean?" Here is the trap. The obvious definition — the piece is allowed to move that way — is incomplete, and an interviewer will quietly accept it if you offer it, then dismantle you in the analysis act. Full legality has a second clause: a move that leaves your own king attacked is illegal, no matter how correctly the piece moved. That clause is what makes pinned pieces immovable, what forbids ignoring a check, and — as lesson 02 shows — it's the requirement that forces the entire two-layer architecture.

Raise it yourself. "I want to confirm: is a move that exposes my own king illegal — full legality — or are we validating piece movement only?" That sentence, early, is worth more than any code you'll write later, because it announces that you know where this problem's complexity actually lives. Candidates who don't ask discover the requirement when the interviewer slides a pinned bishop sideways.

The remaining questions, and why each matters

"Does the validator know whose turn it is?" Yes — moving the opponent's piece is illegal. Trivial to ask, and it puts turn into your input contract now instead of retrofitting it.

"What's the input shape?" Usually your choice; from-square and to-square is fine. Asking confirms the boundary: you receive a proposed move and return a verdict — you don't generate suggestions or judge quality.

"How much of the rulebook is v1?" The prompt invited this. A good v1 boundary: normal moves and captures for all six piece types, full legality included; the rulebook's trickier special cases — the ones that make chess programmers sigh — deferred. Volunteering a staged scope shows judgment; pretending you'll implement tournament-complete chess in 45 minutes shows the opposite.

"Board representation — mine to choose?" Yours. An 8×8 grid is fine; nobody expects engine-grade cleverness (lesson 04 tours the fancier options and when they matter).

"What performance bar?" Interactive: a UI validating as a human drags pieces. Thousands of validations per second is plenty — which licenses simple, readable algorithms and honest complexity talk instead of premature optimization.

The requirement set this chapter builds against

Legality      FULL — piece moves correctly AND the mover's king
              is not left attacked; turn order enforced
Input         (from-square, to-square) proposed move + position
Verdict       legal / illegal; validation only — no move suggestions
Scope v1      all six piece types, normal moves and captures;
              remaining special rules of the rulebook deferred
Board         your representation; 8x8 is fine
Performance   interactive UI rates — thousands of checks/sec is plenty
Out of scope  engine/AI, game-end declarations, clocks, draw rules

As with every chapter: a live interviewer's answers may differ — maybe their v1 wants game-end detection, or a stricter performance bar. The skill is the conversation, and above all the instinct to ask what "legal" fully means before believing you already know.

Key takeaway

The chess validator's requirements conversation hinges on one question: does legality include king safety? Full legality — a move may not leave your own king attacked — is the requirement that shapes the whole design, and raising it yourself is the round's biggest single signal. Around it: pin the turn rule, the input shape, a staged v1 scope you volunteer, and an interactive performance bar that licenses simple algorithms.

Enjoying the preview?

Create a free account to unlock the rest of this course, the in-browser judge, and live AI mock interviews.

Sign up free to continue