Learn / Library / Brainteasers
Whoever empties loses
There are boxes holding , and marbles. players alternate; a move takes any positive number of marbles from exactly one box. The player who takes the very last marble loses. You move first and both players play optimally. Exactly one first move guarantees you a win. How many marbles does that move take?
Checking an answer needs JavaScript. The hint and the solution open without it.
Hint
While some box still holds or more marbles, play as in the ordinary game where taking the last marble wins.
Solution
- In this version the rule is the same as in the ordinary game as long as some box has at least marbles: move so that the XOR of the sizes is .
- Only at the end, when your move would leave every box with at most marble, do you leave an odd number of single marbles instead.
- Here XOR is , and XOR is , so the position is won for you.
- Only the box of can be lowered to XOR , which is ; this leaves , and , with XOR and a box still larger than .
- So the winning move takes marble, and the answer is .
Answer: