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 will have size 1 0 i + d i , where d i is the number rolled on the 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 b a where a and b are coprime positive integers. What is the value of a + b ?
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.
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 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.
Log in to reply
Thank you for the advice :) I will take note of it when I write a solution next time!
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 , but I do not agree that it is trivial without justification (no power of 2 is a multiple of 3 but there given any power of 2 , and for any integer a there exists an integer b such that 2 a + 2 b is a multiple of 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 , and that the losing player cannot change his fate). Nor is it clear why thinking modulo 3 is useful given that only powers of 2 can be removed, unless you justify the previous result.
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 " piles and an odd number of " 1 " piles, then decrease a " 1 " pile by 1 (or 4 on the initial turn).
If there are an odd number of " 1 " piles and an odd number of " 2 " piles, then decrease a " 2 " pile by 1 (or 4 on the initial turn).
If there are an odd number of " 0 " piles and an odd number of " 2 " piles, then decrease a " 2 " pile by 2 (or, on the initial turn, decrease a " 0 " pile by 4 ).
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 stones (modulo 3 ) in them for each 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.
I don't follow the second half of the first paragraph. For example, 1 and 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 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.
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 then if the pile of stone is a multiple of 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 , 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 ) , it should be a bit clearer.
All in all, thank you for your comment nonetheless.
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.
I'm sorry there's a typo , it's ( 2 4 ) = 6 .
Log in to reply
Also in (a) it should say 2 4 rather than 4 4 .
But all in all, a very nice solution!
Let G ( n ) be the Grundy number of a single pile of size n . Then G ( 0 ) = 1 , G ( 1 ) = 1 , and G ( n ) = m e x { G ( n − 2 j ) ∣ ∣ j ≥ 0 , 2 j ≤ n } n ≥ 2 I claim that G ( n ) ∈ { 0 , 1 , 2 } and G ( n ) ≡ n modulo 3 . This is easily proved by induction. Certainly G ( 2 ) = m e x { G ( 0 ) , G ( 1 ) } = 2 . Suppose that N ≥ 3 and the result holds for all G ( n ) with 0 ≤ n ≤ N − 1 . Since 4 ≡ 1 modulo 3 , we deduce that G ( N − 2 2 j ) ≡ G ( N − 1 ) G ( N − 2 2 j + 1 ) ≡ G ( N − 2 ) modulo 3 for all j ≥ 0 , and hence G ( N ) = m e x { G ( N − 1 ) , G ( N − 2 ) } . That the result holds for 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 counters is G ( x 1 , x 2 , x 3 , x 4 ) = G ( x 1 ) ⊕ G ( x 2 ) ⊕ G ( x 3 ) ⊕ G ( x 4 ) and the position is a losing one precisely when G ( x 1 , x 2 , x 3 , x 4 ) = 0 . Thus we are interested in the Grundy score of the opening position G ( 1 0 + d 1 , 1 0 0 + d 2 , 1 0 0 0 + d 3 , 1 0 0 0 0 + d 4 ) which is the same as G ( 1 + d 1 ) ⊕ G ( 1 + d 2 ) ⊕ G ( 1 + d 3 ) ⊕ G ( 1 + d 4 ) Since each of G ( 1 + d j ) is either 0 , 1 or 2 , this opening Grundy score is either 0 , 1 , 2 or 3 , and is easy to calculate. Let N 0 be the number of d j such that G ( 1 + d j ) = 0 , let N 1 be the number of d j such that G ( 1 + d j ) = 1 , and let N 2 be the number of d j such that G ( 1 + d j ) = 2 . Then it is clear that the value of G ( 1 0 + d 1 , 1 0 0 + d 2 , 1 0 0 0 + d 3 , 1 0 0 0 0 + d 4 ) is determined by the parity of the numbers N 0 , N 1 , N 2 (which, of course, add to 4 ).
N 0 E O O E N 1 E O E O N 2 E E O O G 0 1 2 3 In each of the opening positions with winning Grundy scores, it is possible to make a winning move by taking 4 off a pile:
If N 0 and N 1 are odd, take 4 off a pile with G ( 1 + d j ) = 1 , reducing the number N 1 by 1 and increasing the number N 0 by 1 , making both even.
If N 0 and N 2 are odd, take 4 off a pile with G ( 1 + d j ) = 0 , reducing the number N 0 by 1 and increasing the number N 2 by 1 , making both even.
If N 1 and N 2 are odd, take 4 off a pile with G ( 1 + d j ) = 2 , reducing the number N 2 by 1 and increasing the number N 1 by 1 , making both even.
Since each pile contains at least 1 0 stones initially, there is no difficulty taking 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 are all even. Note that there are two values of d for which G ( 1 + d ) = 0 three values of d for which G ( 1 + d ) = 1 , and three for which or G ( 1 + d ) = 2 . N 0 4 0 0 2 2 0 N 1 0 4 0 2 0 2 N 2 0 0 4 0 2 2 C o u n t 2 4 = 1 6 3 4 = 8 1 3 4 = 8 1 ( 2 4 ) × 2 2 × 3 2 = 2 1 6 ( 2 4 ) × 2 2 × 3 2 = 2 1 6 ( 2 4 ) × 3 2 × 3 2 = 4 8 6 making a grand total of 1 0 9 6 losing positions. Thus there are 8 4 − 1 0 9 6 = 3 0 0 0 winning opening positions for Lino, and hence his probability of winning is 8 4 3 0 0 0 = 5 1 2 3 7 5 . Thus the required answer is 3 7 5 + 5 1 2 = 8 8 7 .
Consider first if there were only one pile of n stones. We can give it a "Nim-sum" of n m o d 3 . If the Nim-sum is 0 the player to move loses (I'll call this a losing position), otherwise the player to move wins.
Since 3 ∤ 2 k , if the position is 0 then any move makes it non-zero. And if the position is 1 then we can remove 2 0 = 1 stones, and if the position is 2 we can remove 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 .
Now to consider the condition that Lino must remove 4 stones to start. By the pigeonhole principle, since there are 3 possible Nim-sums, any position with 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 } They can't be the same otherwise the Nim-sum of the entire position would be 0 . In these positions, the following moves leave a losing position respectively: { 1 → 0 } , { 2 → 1 } , { 0 → 2 }
Each of those moves can be done by removing 4 ≡ 1 m o d 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 , each pile will start off with a Nim-sum of P ( 0 ) = 8 3 , P ( 1 ) = 8 3 , or P ( 2 ) = 8 2 .
Here is a list of all the losing combinations (i.e. Nim-sum zero) along with how many of the 8 4 possible starting positions have that combination:
0 0 0 0 1 1 1 1 2 2 2 2 0 0 1 1 0 0 2 2 1 1 2 2 → ( 0 4 ) 3 4 → ( 0 4 ) 3 4 → ( 0 4 ) 2 4 → ( 2 4 ) 3 4 → ( 2 4 ) 3 2 2 2 → ( 2 4 ) 3 2 2 2 Totalling those up gives 8 4 1 0 9 6 = 5 1 2 1 3 7 . The number of winning positions is the complement of this, i.e. 5 1 2 3 7 5
Problem Loading...
Note Loading...
Set Loading...
Now, because in the question we are only allowed to take an amount of stones that is a power of 2 , it is instructive to think ( m o d 3 ) to hunt for losing positions. In fact, another hint to looking ( m o d 3 ) is that we want Lino to remove 4 stones. So, trivially, if a pile of stone is a multiple of 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 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 ) 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 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 ) . Obviously once Lino makes his move of removing 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 = 4 0 9 6 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 would result in piles of ≡ 1 ( m o d 3 ) , a dice throw of 1 , 4 , 7 would result in piles of ≡ 2 ( m o d 3 ) and a dice throw of 2 , 5 would result in piles of ≡ 0 ( m o d 3 ) . Now, for it to be a losing position for Lino:
(a) if all 4 piles are of a certain residue class. This is trivial to count. It's just 3 4 + 3 4 + 4 4 = 1 7 8
(b) or 2 piles each are of 2 different residue classes. Firstly, there are ( 2 = 6 4 ) 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 ) = 9 1 8 .
Combining both scenarios, we find that the fraction that we desire is 1 − 4 0 9 6 9 1 8 + 1 7 8 = 5 1 2 3 7 5 and a + b is 887 .