Question presented to candidate: "Build a playable Tic-Tac-Toe game for two people sharing one screen. Show a 3 by 3 board, let X and O take turns, announce the winner or a draw, highlight the winning line, and give me a way to start again. Keep the game rules testable on their own."
Requirements:
- A 3 x 3 board of clickable cells; X always moves first, then the players alternate.
- A filled cell cannot be played again, and no moves are accepted once the game is over.
- Detect a win (three in a row, column or diagonal) and highlight the winning cells; detect a draw when the board is full.
- A status line: whose turn it is, who won, or that it is a draw.
- A Restart button that clears the board.
What a strong answer should cover:
- A minimal state model: the nine cells are the only state; whose turn it is, the winner and the draw are derived from them.
- The win check as a list of the 8 winning lines, written as a pure function outside the component.
- Immutable updates: a move returns a new board array instead of changing the old one.
- Guarding illegal moves in the logic, not only by disabling buttons.
- Accessibility: real buttons, a label per cell that includes its contents, and a status region that screen readers announce.
- How it would extend: move history and time travel, bigger boards, a computer opponent.
Clarifying questions expected:
- "Is it two humans on one device, or should one side be a computer player?"
- "Do you want move history or undo, or just restart?"
- "Should the board size be fixed at 3 x 3?"
Code / implementation expected: Yes. A working component in the chosen framework, with the win check as a separate pure function, in about 30-40 minutes.