Game technique · Nim
Nim-Sum and XOR Strategy
XOR the heap sizes to find the Nim-sum. In normal-play Nim, a nonzero result means the player to move can leave a zero Nim-sum.
🎮 Play Nim →How it works
XOR the heap sizes to find the Nim-sum. In normal-play Nim, a nonzero result means the player to move can leave a zero Nim-sum.
Example
For heaps of 3, 4, and 5, the Nim-sum is 2. Reduce the heap of 3 to 1, leaving 1 XOR 4 XOR 5 = 0.
Key point
XOR the heap sizes to find the Nim-sum. In normal-play Nim, a nonzero result means the player to move can leave a zero Nim-sum.