An impartial game played with heaps of counters: a move removes a positive number of counters from exactly one heap. Under the normal-play convention, a position is losing exactly when the bitwise exclusive or of its heap sizes is zero.
A Nim heap of size contains counters and permits removing any positive number, leaving a heap of any size . Under the normal-play convention, its Grundy number is : the reachable values are exactly , whose mex is .
For several heaps, a turn changes exactly one heap. Their combined value is the Nim-sum of the heap sizes, so heaps of sizes three and three form a losing position even though either heap alone is winning. The ability to remove arbitrarily many counters is part of the rule; a bounded-removal subtraction game has different values.
The bitwise exclusive or of a list of nonnegative integers. For heap sizes in ordinary Nim, a zero nim-sum characterizes a losing position under the normal-play convention.
Articles by others on the same topic
Nim is a high-level, statically typed programming language designed for efficiency, expressiveness, and versatility. It combines elements from various programming paradigms, including procedural, functional, and object-oriented programming. Key features of Nim include: 1. **Performance**: Nim compiles to efficient C, C++, or JavaScript code, allowing for high-performance applications while still providing the expressive benefits of a high-level language.