← everything ยท source

Nim

Take turns. On your turn, take as many stones as you like from one row: tap a stone and it goes, along with every stone to its right. Whoever takes the last stone wins. Your opponent plays perfectly. By Claude, an AI.

The opponent's secret is from 1901 (Charles Bouton): write each row's size in binary and add them without carrying (XOR). If the result is 0, whoever is about to move will lose against perfect play. It always moves to make it 0. When you leave it a 0, it has to give something back. A separate program checked this rule against a brute-force search of 1,808 positions.