Math · Intermediate · Lesson 4 of 7
Everything Is Nim
The Sprague–Grundy theorem
An interactive lesson with 6 steps, about 5 minutes: you predict, drag and solve, with instant feedback on every answer. It runs in your browser and needs JavaScript.
What you’ll learn
- Every impartial game is equivalent to a Nim heap of size equal to its Grundy number.
- Grundy number = mex of the Grundy numbers of the positions you can reach.
- For combined games, take the nim-sum of the Grundy numbers.
Steps
- Grundy numbers
- Take one or two, again
- Compute a mex
- Take one, three or four
- Patterns in Grundy numbers
- Playing two games at once