Let he who has no sin cast the first stone

Calvin and Lino are playing a game with 4 piles of stones. At the start of the game, Calvin rolls four 8-sided dice, each with the numbers 0 through 7 on them, to help in determining the sizes of the piles of stones. Pile i i will have size 1 0 i + d i , 10^i + d_i, where d i d_i is the number rolled on the i i th die.

Players take turns removing stones from the piles, and Lino gets to make the first move. On a player's turn, that player is allowed to remove a number of stones that is a power of 2 from one of the piles. The last player who makes a move is the winner.

Assuming that Calvin and Lino both play optimally, the probability that Lino is able to remove 4 stones from a pile on his first move and still win the game can be expressed as a b \frac{a}{b} where a a and b b are coprime positive integers. What is the value of a + b a + b ?


The answer is 887.

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

3 solutions

Anqi Li
Nov 10, 2013

Now, because in the question we are only allowed to take an amount of stones that is a power of 2 2 , it is instructive to think ( m o d 3 ) (mod 3) to hunt for losing positions. In fact, another hint to looking ( m o d 3 ) (mod 3) is that we want Lino to remove 4 stones. So, trivially, if a pile of stone is a multiple of 3 3 it is a losing position and if otherwise, then it is a winning position. Also, because there are multiple piles, it is also a good idea to think of parity . Because, suppose all 4 4 piles are in a winning position, it is clear that the second player would win. Extending this logic, we see that if an even number of piles contain either 1 , 2 ( m o d 3 ) \equiv 1,2 (mod 3 ) number of stones, then it would be a losing position for the first player. Obviously, if we are not in such a configuration we may always end up in this configuration and if we are in such a configuration we may always enter a new configuration. Basically, this means that if there is an odd number of piles for each residue m o d 3 mod 3 then it is a winning position.

Now, consider if there is an even number of piles of each 0 , 1 , 2 ( m o d 3 ) \equiv 0,1,2 (mod 3) . Obviously once Lino makes his move of removing 4 4 stones, he would change the parity of the number of piles of that residue, thus making it a winning position for Calvin. It is routine to verify that if the starting configuration is otherwise, Lino can always, with his first move, make it a losing position for Calvin, in other words, make the number of piles per residue even (the interested reader should really attempt this!)

Now, notice that the losing configurations for Lino are easier to count. Whence we use the method counting the compliment . Keep in mind that there is a total of 4 6 = 4096 4^6 = 4096 different starting positions. We will group the dice throws into the different residue classes for easy referencing later, so a dice throw of 0 , 3 , 6 0, 3, 6 would result in piles of 1 ( m o d 3 ) \equiv 1 (mod 3) , a dice throw of 1 , 4 , 7 1, 4, 7 would result in piles of 2 ( m o d 3 ) \equiv 2 (mod 3) and a dice throw of 2 , 5 2, 5 would result in piles of 0 ( m o d 3 ) \equiv 0 (mod 3) . Now, for it to be a losing position for Lino:

(a) if all 4 4 piles are of a certain residue class. This is trivial to count. It's just 3 4 + 3 4 + 4 4 = 178 3^4 + 3^4 + 4^4 = 178

(b) or 2 2 piles each are of 2 2 different residue classes. Firstly, there are ( 4 2 = 6 ) 4 \choose 2 = 6 ways to assign each pile a certain residue class. So the total number of ways is 6 ( 3 2 × 2 2 + 3 2 × 3 2 + 3 2 × 2 2 ) = 918 6(3^2 \times 2^2 + 3^2 \times 3^2 + 3^2 \times 2^2) = 918 .

Combining both scenarios, we find that the fraction that we desire is 1 918 + 178 4096 = 375 512 1 - \frac{918+178}{4096} = \frac{375}{512} and a + b a + b is 887 .

The first paragraph is a bit hard to read through. You start off talking about the problem given in the question, but then switch to talking about "if a pile of stone is a multiple of 3 3 it is a losing position ..." It is not immediately clear if you are talking about a game with only a single pile, or if you mean that when one of the 4 piles has this size the game is losing. I try to note a shift in context when writing a proof by using a sentence such as "Consider a single pile of stones" to make it clear that the scope has changed.

Also, when writing solutions, it is advisable to avoid using the word trivially, since if something is trivial, it should be not much longer to just include the explanation. And sometimes, what seems trivial to one person is not to another.

Lino Demasi - 7 years, 7 months ago

Log in to reply

Thank you for the advice :) I will take note of it when I write a solution next time!

Anqi Li - 7 years, 7 months ago

Hmmm. There are a lot of (correct) statements here, but not much proof. You say that it is trivial that a losing number of stones a pile is a multiple of 3 3 , but I do not agree that it is trivial without justification (no power of 2 2 is a multiple of 3 3 but there given any power of 2 2 , and for any integer a a there exists an integer b b such that 2 a + 2 b 2^a+2^b is a multiple of 3 3 would do, for example, since this shows that the winning player can always force the losing player to face a number of stones that is a multiple of 3 3 , and that the losing player cannot change his fate). Nor is it clear why thinking modulo 3 3 is useful given that only powers of 2 2 can be removed, unless you justify the previous result.

Mark Hennings - 7 years, 7 months ago

Log in to reply

In my opinion, Anqi exaggerated a bit in the second paragraph by saying "obviously" and "is it routine" etc. but I would still call it a proof.

The part where he said "the interested reader should really attempt this" can be done as follows:

If there are an odd number of " 0 0 " piles and an odd number of " 1 1 " piles, then decrease a " 1 1 " pile by 1 1 (or 4 4 on the initial turn).

If there are an odd number of " 1 1 " piles and an odd number of " 2 2 " piles, then decrease a " 2 2 " pile by 1 1 (or 4 4 on the initial turn).

If there are an odd number of " 0 0 " piles and an odd number of " 2 2 " piles, then decrease a " 2 2 " pile by 2 2 (or, on the initial turn, decrease a " 0 0 " pile by 4 4 ).

Peter Byers - 7 years, 7 months ago

Log in to reply

What we have a is proof outline. It is a sequence of statements that say that "(a), (b), (c) can be shown, and the losing positions are those where there are an even number of piles with j j stones (modulo 3 3 ) in them for each j = 0 , 1 , 2 j=0,1,2 ". But none of these statements is justified, save by saying that each step is trivial, clear, routine, or an exercise for the reader. That each of these steps take a number of lines to establish (like you did for one of them above) indicates that these are key steps in the argument, and not matters that can be left out.

I have no problems with how the losing positions are counted after that.

Mark Hennings - 7 years, 6 months ago

I don't follow the second half of the first paragraph. For example, 1 1 and 2 2 are winning positions for a single pile. You say, " suppose all 4 piles are in a winning position, it is clear that the second player would win." But if the piles are 1 , 1 , 1 , 2 1,1,1,2 then the first player wins. And "Obviously, if we are not in such a configuration we may always end up in this configuration " could do with some more explanation.

Matt McNabb - 7 years, 7 months ago

Log in to reply

Indeed, refer to Lino's comment, my first paragraph is quite confusing and I'm sorry about that.

Basically, we first consider a single pile of stones , since each move is not a multiple of 3 3 then if the pile of stone is a multiple of 3 3 it is a losing position and if otherwise it is a winning position.

And I tried to not consider the limitation on Lino when I did the analysis on multiple piles. For your example, 1 , 1 , 1 , 2 1, 1, 1 , 2 , indeed, my sentence "suppose all 4 piles are in a winning position, etc." is extremely confusing. Sorry for that mistake. Well, I was trying to explain why one would think about parity and I have to brush up on my solution writing skills to explain my motivation better.

As for the second part of your comment, if we consider ( m o d 3 ) \pmod 3 , it should be a bit clearer.

All in all, thank you for your comment nonetheless.

Anqi Li - 7 years, 7 months ago

While I do agree that motivation etc. should be included, I think in this case you went a bit overboard and the overall scope of the solution was lost.

Michael Tong - 7 years, 6 months ago

I'm sorry there's a typo , it's ( 4 2 ) 4 \choose 2 = 6 = 6 .

Anqi Li - 7 years, 7 months ago

Log in to reply

Also in (a) it should say 2 4 2^4 rather than 4 4 4^4 .

But all in all, a very nice solution!

Peter Byers - 7 years, 7 months ago

Log in to reply

Yup sorry for that

Anqi Li - 7 years, 7 months ago
Mark Hennings
Nov 12, 2013

Let G ( n ) G(n) be the Grundy number of a single pile of size n n . Then G ( 0 ) = 1 G(0) = 1 , G ( 1 ) = 1 G(1) = 1 , and G ( n ) = m e x { G ( n 2 j ) j 0 , 2 j n } n 2 G(n) \; = \; \mathrm{mex}\big\{ G(n-2^j) \, \big| \, j \ge 0\,,\,2^j \le n \big\} \qquad n \ge 2 I claim that G ( n ) { 0 , 1 , 2 } G(n) \in \{0,1,2\} and G ( n ) n G(n) \equiv n modulo 3 3 . This is easily proved by induction. Certainly G ( 2 ) = m e x { G ( 0 ) , G ( 1 ) } = 2 G(2) = \mathrm{mex}\{G(0),G(1)\} = 2 . Suppose that N 3 N \ge 3 and the result holds for all G ( n ) G(n) with 0 n N 1 0 \le n \le N-1 . Since 4 1 4 \equiv 1 modulo 3 3 , we deduce that G ( N 2 2 j ) G ( N 1 ) G ( N 2 2 j + 1 ) G ( N 2 ) G(N - 2^{2j}) \, \equiv \, G(N-1) \qquad G(N-2^{2j+1}) \, \equiv \, G(N-2) modulo 3 3 for all j 0 j \ge 0 , and hence G ( N ) = m e x { G ( N 1 ) , G ( N 2 ) } G(N) \,=\, \mathrm{mex}\{G(N-1),G(N-2)\} . That the result holds for G ( N ) G(N) follows by checking cases.

As usual, the Grundy score for a board of this game, consisting of four piles containing x 1 , x 2 , x 3 , x 4 x_1,x_2,x_3,x_4 counters is G ( x 1 , x 2 , x 3 , x 4 ) = G ( x 1 ) G ( x 2 ) G ( x 3 ) G ( x 4 ) G(x_1,x_2,x_3,x_4) \; = \; G(x_1) \oplus G(x_2) \oplus G(x_3) \oplus G(x_4) and the position is a losing one precisely when G ( x 1 , x 2 , x 3 , x 4 ) = 0 G(x_1,x_2,x_3,x_4)=0 . Thus we are interested in the Grundy score of the opening position G ( 10 + d 1 , 100 + d 2 , 1000 + d 3 , 10000 + d 4 ) G(10+d_1,100+d_2,1000+d_3,10000+d_4) which is the same as G ( 1 + d 1 ) G ( 1 + d 2 ) G ( 1 + d 3 ) G ( 1 + d 4 ) G(1+d_1) \oplus G(1+d_2) \oplus G(1+d_3) \oplus G(1+d_4) Since each of G ( 1 + d j ) G(1+d_j) is either 0 0 , 1 1 or 2 2 , this opening Grundy score is either 0 , 1 , 2 0,1,2 or 3 3 , and is easy to calculate. Let N 0 N_0 be the number of d j d_j such that G ( 1 + d j ) = 0 G(1+d_j) = 0 , let N 1 N_1 be the number of d j d_j such that G ( 1 + d j ) = 1 G(1+d_j)=1 , and let N 2 N_2 be the number of d j d_j such that G ( 1 + d j ) = 2 G(1+d_j)=2 . Then it is clear that the value of G ( 10 + d 1 , 100 + d 2 , 1000 + d 3 , 10000 + d 4 ) G(10+d_1,100+d_2,1000+d_3,10000+d_4) is determined by the parity of the numbers N 0 , N 1 , N 2 N_0,N_1,N_2 (which, of course, add to 4 4 ).

N 0 N 1 N 2 G E E E 0 O O E 1 O E O 2 E O O 3 \begin{array}{|c|c|c|c|}\hline N_0 & N_1 & N_2 & G \\ \hline E & E & E & 0 \\ O & O & E & 1 \\ O & E & O & 2 \\ E & O & O & 3 \\ \hline \end{array} In each of the opening positions with winning Grundy scores, it is possible to make a winning move by taking 4 4 off a pile:

  1. If N 0 N_0 and N 1 N_1 are odd, take 4 4 off a pile with G ( 1 + d j ) = 1 G(1+d_j)=1 , reducing the number N 1 N_1 by 1 1 and increasing the number N 0 N_0 by 1 1 , making both even.

  2. If N 0 N_0 and N 2 N_2 are odd, take 4 4 off a pile with G ( 1 + d j ) = 0 G(1+d_j)=0 , reducing the number N 0 N_0 by 1 1 and increasing the number N 2 N_2 by 1 1 , making both even.

  3. If N 1 N_1 and N 2 N_2 are odd, take 4 4 off a pile with G ( 1 + d j ) = 2 G(1+d_j)=2 , reducing the number N 2 N_2 by 1 1 and increasing the number N 1 N_1 by 1 1 , making both even.

Since each pile contains at least 10 10 stones initially, there is no difficulty taking 4 4 stones off any pile. Let us count the number of losing starting positions (for Lino), namely the ones where N 0 , N 1 , N 2 N_0,N_1,N_2 are all even. Note that there are two values of d d for which G ( 1 + d ) = 0 G(1+d)=0 three values of d d for which G ( 1 + d ) = 1 G(1+d)=1 , and three for which or G ( 1 + d ) = 2 G(1+d) = 2 . N 0 N 1 N 2 C o u n t 4 0 0 2 4 = 16 0 4 0 3 4 = 81 0 0 4 3 4 = 81 2 2 0 ( 4 2 ) × 2 2 × 3 2 = 216 2 0 2 ( 4 2 ) × 2 2 × 3 2 = 216 0 2 2 ( 4 2 ) × 3 2 × 3 2 = 486 \begin{array}{|c|c|c|c|} \hline N_0 & N_1 & N_2 & \mathrm{Count} \\ \hline 4 & 0 & 0 & 2^4 = 16 \\ 0 & 4 & 0 & 3^4 = 81 \\ 0 & 0 & 4 & 3^4 = 81 \\ 2 & 2 & 0 & {4 \choose 2}\times2^2\times3^2 = 216 \\ 2 & 0 & 2 & {4 \choose 2}\times2^2\times3^2 = 216 \\ 0 & 2 & 2 & {4 \choose 2}\times3^2\times3^2 = 486 \\ \hline \end{array} making a grand total of 1096 1096 losing positions. Thus there are 8 4 1096 = 3000 8^4 - 1096 = 3000 winning opening positions for Lino, and hence his probability of winning is 3000 8 4 = 375 512 \frac{3000}{8^4} = \frac{375}{512} . Thus the required answer is 375 + 512 = 887 375+512 = 887 .

Matt McNabb
Nov 14, 2013

Consider first if there were only one pile of n n stones. We can give it a "Nim-sum" of n m o d 3 n \mod 3 . If the Nim-sum is 0 0 the player to move loses (I'll call this a losing position), otherwise the player to move wins.

Since 3 2 k 3 \nmid 2^k , if the position is 0 0 then any move makes it non-zero. And if the position is 1 1 then we can remove 2 0 = 1 2^0 = 1 stones, and if the position is 2 2 we can remove 2 1 = 2 2^1 = 2 stones. So, this is a correct definition for a Nim-sum because if it is non-zero then there exists a move to make it zero; and if it is zero then all moves make it non-zero.

As an aside, that means that the rule "remove any power of two" could be replaced with "remove either one or two stones" and the outcome of the game would remain the same.

According to the Sprague-Grundy theorem, we can extend this from one pile to multiple piles by taking the bitwise-XOR of the Nim-sum of each pile, i.e. i i = 0 , 1 2 = 0 , 1 0 = 1 , 2 0 = 2 i ⊕ i = 0, 1 ⊕ 2 = 0, 1 ⊕ 0 = 1, 2 ⊕ 0 = 2 .

Now to consider the condition that Lino must remove 4 4 stones to start. By the pigeonhole principle, since there are 3 3 possible Nim-sums, any position with 4 4 piles must have two piles with the same Nim-sum.

Now consider the remaining two piles. In a winning position, they must be either { 0 , 1 } , { 1 , 2 } , or { 0 , 2 } \{0,1\}, \{1,2\}, \mbox{or} \{0,2\} They can't be the same otherwise the Nim-sum of the entire position would be 0 0 . In these positions, the following moves leave a losing position respectively: { 1 0 } , { 2 1 } , { 0 2 } \{1 \rightarrow 0\}, \{2 \rightarrow 1\}, \{0 \rightarrow 2\}

Each of those moves can be done by removing 4 1 m o d 3 4 \equiv 1 \mod 3 stones, so this condition on Lino's first move can be fulfilled in any winning position.

Finally, we just need to count up how many winning positions there are. In fact it's simpler to count the number of losing positions. Since 1 0 i 1 m o d 3 10^i \equiv 1 \mod 3 , each pile will start off with a Nim-sum of P ( 0 ) = 3 8 , P ( 1 ) = 3 8 , or P ( 2 ) = 2 8 P(0) = {3 \over 8}, P(1) = {3 \over 8}, \mbox{or} P(2) = {2 \over 8} .

Here is a list of all the losing combinations (i.e. Nim-sum zero) along with how many of the 8 4 8^4 possible starting positions have that combination:

0000 ( 4 0 ) 3 4 1111 ( 4 0 ) 3 4 2222 ( 4 0 ) 2 4 0011 ( 4 2 ) 3 4 0022 ( 4 2 ) 3 2 2 2 1122 ( 4 2 ) 3 2 2 2 \begin{aligned} 0000 &\rightarrow \binom{4}{0} 3^4 \\ 1111 &\rightarrow \binom{4}{0} 3^4 \\ 2222 &\rightarrow \binom{4}{0} 2^4 \\ 0011 &\rightarrow \binom{4}{2} 3^4 \\ 0022 &\rightarrow \binom{4}{2} 3^2 2^2 \\ 1122 &\rightarrow \binom{4}{2} 3^2 2^2 \\ \end{aligned} Totalling those up gives 1096 8 4 = 137 512 {1096 \over 8^4} = {137 \over 512} . The number of winning positions is the complement of this, i.e. 375 512 \boxed{375 \over 512}

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...