TITLE: Ordered Nim game
QUESTION [9 upvotes]: Consider the following variant of Nim:
There are two players and $n$ piles of stones, with sizes $a_1,\dots,a_n$, such that $a_i\leq a_j$ for any $i<j$.
A move consists of removing a positive number of stones from any pile, such that inequalities are preserved.
A player loses if all piles are empty.
What are the winning positions, or, more generally, what is the Sprague-Grundy value of a position?

REPLY [9 votes]: As Alex conjectures in a comment, the Grundy value is $$(a_n-a_{n-1}) \oplus (a_{n-2}-a_{n-3}) \oplus \cdots \oplus (a_2-a_1)$$ if $n$ is even, or $$(a_n-a_{n-1}) \oplus \cdots \oplus (a_3-a_2) \oplus a_1$$ if $n$ is odd.
To see this, let $b_i=a_i+i$, and place checkers in the spaces $b_1,b_2,\dots,b_n$ on a half-infinite strip. On your turn, you may move a checker any distance towards the end of the strip, without passing through a square occupied by another piece.
This is the "Silver Dollar game with No Silver Dollar": the piles are the gaps between alternating pairs of pieces. Any move to increase the size of a pile is immediately reversible, so the Grundy values are the same as in Nim.