LibraryQuant puzzles

Nim, the XOR Invariant and Misere Play

Quant puzzle · medium · members

The question

Three piles hold 5, 7 and 9 counters. Players alternate. A move takes any positive number of counters from exactly one pile. Under the normal rule the player who takes the last counter on the board wins.

  1. Who wins from 5, 7, 9 with perfect play, and what is the move?
  2. Prove the rule you used, in full.
  3. Now change the win condition: the player who takes the last counter loses. Who wins from 5, 7, 9? Who wins from 1, 1, 1?
  4. State the rule for the changed condition and say why so little of the analysis moves.

Hint

Write the three pile sizes in binary and compare the columns. For the changed rule, ask at which stage of the game the two win conditions can actually lead to different moves.

The idea behind it

A quantity that is zero exactly on the losing positions and that no single move can preserve is a complete solution to a game. Bitwise exclusive or is that quantity for Nim, and the misere variant shows how little of the analysis a changed win condition disturbs.

The worked solution is for members

You have the question, a hint and the idea. It finds the winning move from the given piles, explains why it wins, and shows how the strategy changes under the reversed rule.

Further reading

Related problems

Topics

Also in the library