Nim: the matchstick game with a winning strategy hidden in binary
Set out a few piles of matches. Players take turns removing any number from one pile, and whoever takes the last match wins.
It looks like pure guesswork, but there's a complete strategy. Write each pile size in binary and combine them with XOR (add each column without carrying). If the result is zero, the player about to move is losing against perfect play. Otherwise, there's always a move that makes it zero.
I've used it to beat my family repeatedly before teaching them the trick. What's your favourite game with a secret mathematical strategy?
Comments · 1
Nim is also the foundation of the Sprague-Grundy theorem, which shows that a huge family of two-player games can be reduced to Nim positions. So the XOR trick is much more widely applicable than a few matchsticks suggest.