Arjun and Beth play a game in which they take turns removing one brick or two adjacent bricks from one "wall" among a set of several walls of bricks, with gaps possibly creating new walls. The walls are one brick tall. For example, a set of walls of sizes and can be changed into any of the following by one move: or

Arjun plays first, and the player who removes the last brick wins. For which starting configuration is there a strategy that guarantees a win for Beth?
- A)
- B)
- C)
- D)
- E)
Answer
B
Key insight
Each wall has a nim-value (mex of reachable values): walls 1–6 give 1,2,3,1,4,3; Beth wins exactly when the XOR is 0, only for (6,2,1).
Solution
This is a sum of independent games (the walls), so use nim-values. Assign each wall size a value : the smallest nonnegative integer not among the values of positions reachable from a single wall of , where a multi-wall position's value is the XOR () of its walls' values. The player to move loses exactly when the total XOR is .
Compute, listing the positions reachable from one wall:
| reachable positions | their values | ||
|---|---|---|---|
| 1 | |||
| 2 | |||
| 3 | |||
| 4 | |||
| 5 | |||
| 6 |
Beth, the second player, wins when the starting XOR is :
- : .
- : . Beth wins.
- : .
- : .
- : .
Only is a losing position for the first player.
The answer is .
Why this works
A position is losing for the mover if every move leads to a winning position, and winning if some move leads to a losing one. For games that split into independent piles, the Sprague–Grundy theorem packages this recursion: each pile gets a "mex" value and piles combine by XOR, with XOR meaning the mover loses. The mirror strategy on symmetric positions like is the special case "equal values XOR to ." Learn to compute small nim-value tables; they settle many take-away games in minutes.
Alternative approach
Without nim-values one can verify (B) by hand: every Arjun move from has a Beth reply into a known losing position, using that mirror-image positions and and are losing for the mover. For instance , , , , , , . Quick eliminations: in Arjun removes the middle two bricks of the to leave and mirrors.
The trap
Treating the game as ordinary Nim (using wall sizes 6, 2, 1 directly) even though removing a middle brick splits a wall into two.
Common mistakes
- Treating the game as ordinary Nim (using wall sizes 6, 2, 1 directly) even though removing a middle brick splits a wall into two.
- Forgetting the split moves when listing what a wall of , or can reach, which corrupts the nim-value table (e.g. getting ).
Techniques
Define states/recurrence and iterate · Exploit symmetry to reduce work or pair up objects