Sprague-Grundy sequence for the ruler game - MathOverflow most recent 30 from http://mathoverflow.net 2013-05-19T11:43:21Z http://mathoverflow.net/feeds/question/39165 http://www.creativecommons.org/licenses/by-nc/2.5/rdf http://mathoverflow.net/questions/39165/sprague-grundy-sequence-for-the-ruler-game Sprague-Grundy sequence for the ruler game Michael Lugo 2010-09-17T23:17:18Z 2010-09-18T01:13:43Z <p>Consider the game "Ruler", which is defined as follows. We start with finitely many coins in a line. A move in this game consists of turning over any number of coins, but they must be consecutive, and the rightmost coin must be turned from heads to tails. Then the position in this game where a coin in the \$n\$th position is heads and all others are tails has Sprague-Grundy value given by</p> <p>\$\$ g(n) = mex \{ 0, g(n-1) , g(n-1) \oplus g(n-2), \cdots, g(n-1) \oplus \cdots \oplus g(1) \} \$\$</p> <p>From here, according to page I-31 of <a href="http://www.math.ucla.edu/~tom/Game_Theory/comb.pdf" rel="nofollow">Ferguson's game theory notes</a>, "it is easy to show" that \$g(n)\$ is the largest power of two dividing \$n\$.</p> <p>Except it's not easy. But it's a nice fact and I'd like to be able to present a proof of it to my students. </p> <p><i>Fair Game</i> by Guy and <i>Winning Ways</i>, the two other sources I've seen this in, both state this without proof. It seems that it might be closely related to results about Gray codes - the partial sums \$g(1), g(1) \oplus g(2), g(1) \oplus g(2) \oplus g(3), \cdots\$ are a binary Gray code for the integers.</p> http://mathoverflow.net/questions/39165/sprague-grundy-sequence-for-the-ruler-game/39182#39182 Answer by zeb for Sprague-Grundy sequence for the ruler game zeb 2010-09-18T01:13:43Z 2010-09-18T01:13:43Z <p>As in all combinatorial game theory problems, we want to use strong induction on \$n\$. So suppose we know it for \$1, ..., n-1\$, and let's prove it for \$n\$.</p> <p>Write \$n\$ in the form \$2^k(2x+1)\$. Then the highest power of \$2\$ dividing \$n-i\$ for \$i&lt;2^k\$ is the same as the highest power of \$2\$ dividing \$i\$, so it's pretty easy to see that by the time we hit \$g(n-1)\oplus \cdots \oplus g(n-2^k+1)\$ we have hit every nimber from \$0\$ to \$2^k-1\$ (by Gray codes, if you like).</p> <p>Now we just have to show that the nimber \$2^k\$ never shows up in that mex. The key idea, I think, is that the order of the highest nonzero bit in the binary representation of \$g(n-1)\oplus \cdots \oplus g(n-i)\$ never decreases as \$i\$ increases. This is because of the fact that for any subsequence \$g(a), g(a+1), ..., g(b)\$ of the largest-power-of-two sequence, the largest value only occurs once (if it occurred twice, there would be a larger power of two halfway in between). Now we just notice that for \$i=2^k\$, we have \$n-i = 2^k(2x+1)-2^k = 2^{k+1}x\$, so \$g(n-1)\oplus \cdots \oplus g(n-i) \ge 2^{k+1}\$ for all \$i\$ greater than or equal to \$2^k\$.</p> <p>Thus \$2^k\$ does not show up in the mex, while every smaller nimber does. The induction is done :)</p>