Calvin and Lino decide to play a game of n -nim. In n -nim, the players start by choosing a random integer k from 1 to 1000 (inclusive). They then make k piles of stones with sizes 1 , 2 , … , k . The players then proceed as in the game of nim. The players alternate turns. On a turn, a player may remove any number of stones from a single pile. The player who removes the last stone wins. If Lino gets to make the first move, the probability that he can win if both he and Calvin play optimally can be expressed as 1 0 0 0 a . What is a ?
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.
Oh man, Lino is so much better than Calvin at this game.
Log in to reply
Obviously Calvin didn't came up with this game. :)
Log in to reply
I asked him if he wanted to play for money, but he said no. :(
Log in to reply
@Lino Demasi – Well, in the question Lino chooses the numbers randomly (as if he knows nothing of the game). If the first player were given the freedom to choose any value of k he liked, he could have certainly chosen k = 1 ! That explains why he said no. :)
Well done, Sreejato.
I spent quite a while working on this problem (I'm guessing you did too, judging by the phrase "tediously by analyzing the possible moves" and similar comments) ... only to realize at the end that it can be done in a very easy way!
Rather than posting a full solution (which would overlap with some of what you already posted) I'll just make two observations:
If ( a 1 , . . . , a n ) is in state L , then the state of ( b 1 , . . . , b m ) is the same as the state of ( a 1 , . . . , a n , b 1 , . . . , b m ) .
So if you show, that for any integer k > 0 , ( 1 , 2 k , 2 k + 1 ) is in state L , then it follows that the state of ( 2 k , 2 k + 1 , b 1 , . . . , b m ) is the same as the state of ( 1 , 1 , 2 k , 2 k + 1 , b 1 , . . . , b m ) , which is the same as the state of ( 1 , b 1 , . . . , b m ) . (Which in turn can be used to should that ( 4 k , 4 k + 1 , 4 k + 2 , 4 k + 3 ) is in state L as you said.)
That seems to be the easiest method of solving the problem.
Log in to reply
After additional thought, let me add a proof of a helpful principle of n -nim.
Let's define A = ( a 1 , . . . a n ) to be "state L ^ " if the total number of stones is even and B = ( b 1 , . . . b n ) is state L where, b k = ⌊ a k / 2 ⌋ .
We can prove that A is state L ^ if and only if it is state L by considering different cases ...
Part I . We need to show that, for A that is state L ^ , no legal move will produce another state L ^ position. This can be seen by considering that the two parts of the definition rule out removing an odd number of stones or an even number of stones, respectively.
Part II . The remaining cases will show that if A is not state L ^ then there a move to a state L ^ position ...
If the total number of stones is odd and B is state L , then at least one a k is odd, and removing one stone from that column yields state L ^ .
Otherwise, B is state W , which means it has a move (possibly more than one) to state L , say by subtracting N from b k leaving b k ′ . If the total number of stones in A is even, simply subtract 2 N from a k . If the total number of stones in A is odd, then subtract from a k whatever odd number would leave either 2 b k ′ or 2 b k ′ + 1 .
Note: That last move is legal because 0 ≤ 2 b k ′ ≤ 2 b k ′ + 1 ≤ a k , and because the amount being subtracted is odd and hence cannot be zero.
Finally, noting that the “base” position, ( 0 ) , is L ^ , this proves that A is state L ^ if and only if it is state L . While that is certainly not necessary to solve the problem, it is very helpful. (For example, we can figure out whether any position is L by writing all its component numbers in base 2.)
Log in to reply
Yeah, that's a much more elegant method than mine. My method of manually analyzing the possible moves is very lengthy and also prone to mistakes. To be honest, at my first try I made a mistake and proved instead that all integers of the form 2 k + 1 dissatisfy the given condition (which is obviously false, take k = 2 for example). But your method is certainly more rigorous and error free.
Correction:- The game ( 1 , 2 , . . . , 7 ) is in state L . It should have been ( 1 , 2 , . . . , 6 )
Can you explain why the state of ( a , b , c , d ) and ( a + 4 , b + 4 , c + 4 , d + 4 ) is the same?
NB. If you can do this then you don't have to exhaustively solve ( 4 , 5 , 6 , 7 ) - you just have to solve ( 0 , 1 , 2 , 3 ) .
The positions with 4 n − 1 stones lose, and all other positions win. We will prove the following lemmas, where L is the set of losing positions, and W is the set of winning positions, L i is a position in L etc., L i L j means the composition of those two positions, and m , n are non-negative integers: L i L j ∈ L L i W j ∈ W ( m , m ) ∈ L ( 2 m , 2 m + 1 , 2 n , 2 n + 1 ) ∈ L
Given those lemmas, the proof runs as follows:
( 1 , 2 , . . . , 4 n − 1 ) loses by decomposing it into other losing positions (Lemma 1): ( 0 , 1 , 2 , 3 ) , ( 4 , 5 , 6 , 7 ) , ..., ( 4 n − 4 , 4 n − 3 , 4 n − 2 , 4 n − 1 ) which all lose according to Lemma 4.
( 1 , 2 , . . . , 4 n − 2 ) must win, otherwise appending 4 n − 1 would generate a winning position (Lemma 2)
( 1 , 2 , . . . , 4 n − 3 ) must win, otherwise appending ( 4 n − 2 , 4 n − 1 ) would generate a winning position (Lemma 2)
( 1 , 2 , . . . , 4 n ) must win, as it is a losing position with the winning position ( 4 n ) appended (Lemma 2).
This covers all cases. Now to prove the lemmas:
Lemma 1: If the position can be decomposed into two losing positions, then the second player's strategy is: "whichever of the two positions the first player moves on, then play the winning move on that position." Such a move must exist because the sub-position is losing, and the result of this is another position L k L j .
Lemma 2: The definition of a winning position is one in which there is such a move that leaves a losing position. Therefore, the first player wins here by making that move on the winning sub-position, leaving L i L k .
Lemma 3: m , m loses because whatever move the first player makes, the second player makes the same move on the other pile, therefire the first player must be faced with p , p where p < m . If p = 0 here then the player has lost.
Lemma 4: If the first player moves 2 m + 1 → 2 m then this is now a position covered by Lemma 2, so the second player wins. Otherwise, the possibilities are:
If the first player moves: 2 m → 2 p for some p , then the second player moves 2 m + 1 → 2 p + 1 . Or if the first player moves 2 m → 2 p + 1 then the second player moves 2 m + 1 → 2 p . Similarly 2 m + 1 → 2 p is met by 2 m → 2 p + 1 and 2 m + 1 → 2 p + 1 is met by 2 m → 2 p .
So the second player can always leave the first player with another position of this category. The smallest such position is ( 0 , 1 , 0 , 1 ) = ( 1 , 1 ) which loses by Lemma 3. QED.
The total number of winning positions is then the number of numbers from 1 to 1 0 0 0 which are not of the form 4 n − 1 , that is clearly 1 0 0 0 ∗ 4 3 = 7 5 0 since 1 0 0 0 is a multiple of 4.
I'm publishing my solution as I think it has a new idea from the other solutions so far, the idea of analyzing a position by decomposing it into a losing position plus another position.
First, we imagine Calvin and Lino follow a strategy: in each turn, a player remove exacly 1 stone, Lino will win if k is an odd number. In fact, it's obvious that they will never follow this strategy since it is not optimal, but we can infer something from this no-optimal strategy: in optimal strategy, each player will try to make the total number of stones to be an even number after his turn; if one player can keep doing that until the end of the game, he will remove the last stone. But how can they do that?
In each pile of stones, we have some "pairs of stone" with the rule that no 2 "pairs of stone" have 1 stone in common. For example, 1-stones-pile has 0 "pairs of stone", 2-stones-pile and 3-stones-pile have 1 "pair of stone", 4-stones-pile and 5-stones-pile have 2 "pairs of stone", ... Now, the optimal strategy will be: Lino, in his first turn, try to make the total number of stones to be an even number, also make the total "pairs of stone" to be an even number; Calvin, in turn, also try to make the total number of stones to be an even number by remove a number of "pairs of stone".
Lino can't keep following this strategy until Calvin has no "pairs of stone" if k ≡ 3 ( m o d 4 ) . Therefore, there are 250 numbers of piles that cannot ensure that Lino wins and the answer is 750.
I like the idea but I don't think your explanation is correct.
For example consider the position ( 1 , 2 , 3 , 4 , 5 , 6 ) . This has 9 "pairs of stone" and 3 single stones. However if Lino removes the 3 pile , then he has made the total number of stones even (18), and the total number of "pairs of stone" even (8). But this is actually a losing move; Calvin wins by taking 4 stones from the 6 pile, leaving ( 1 , 2 , 2 , 4 , 5 ) which is a losing position for Lino (There are also other winning moves for Calvin).
Lino should have taken 3 stones from the 5 pile leaving ( 1 , 2 , 3 ) ( 2 , 4 , 6 ) which is a losing position for Calvin. (There are other winning moves for Lino too)
Yes, I know my solution is not clear enough, my English is too bad. In addition to my solution, I can say something about the first turn of Lino. He not only try to make the number of stones and the number of pairs of stones even number, but also ensure that with each pile, there is also another pile has the same number of pairs of stone. By doing this, if Calvin remove a number of pairs of stone in one pile, Lino, in turn, will remove exacly the same number of pairs of stone in the corresponding pile (corresponding piles: 2-3, 4-5, 6-7, 8-9,...).
With your example, the position (1,2,3,4,5,6), following the strategy, Lino will remove 6 stones in pile-6 in his first move. After that, if Calvin remove 2 stones in pile-2 or pile-5, Lino will remove 2 stones in pile-3 and pile-4, respectively. If Calvin remove 4 stones in pile-4, Lino will remove 4 stones in pile-5
Log in to reply
But Lino removing 6 stones in pile 6 is a losing move, we already agreed that (1,2,3,4,5) is a winning position. (since it's not a 4n-1 position). In fact Calvin wins that position by removing 1 from pile 5.
Sorry, it's my fault, Lino in his first turn remove 5 stones in pile-6
Problem Loading...
Note Loading...
Set Loading...
Call the state of a nim game W if the player about to give a move has a winning strategy, and call it L if the player about to give a move loses irrespective of how he plays (assuming both players play rationally).
We'll first prove that any 4 pile nim game starting with initial configuration ( 4 k , 4 k + 1 , 4 k + 2 , 4 k + 3 ) is in state L . To do this, note that the states of the games ( a , b , c , d ) and ( a + 4 , b + 4 , c + 4 , d + 4 ) are same. Using the fact that the state of the game ( 4 , 5 , 6 , 7 ) is L (this can be proven by analyzing the possible moves; the proof is omitted because of its sheer length), the result immediately follows.
Now we shall prove by induction that all integers of the form 4 k − 1 dissatisfy the given conditions. We shall also prove that all the other integers satisfy the condition. The base case will be to prove that the game ( 1 , 2 , 3 ) is in state L , while the games ( 1 , 2 , 3 , 4 ) , ( 1 , 2 , 3 , 4 , 5 ) , and ( 1 , 2 , 3 , 4 , 5 , 6 , 7 ) are in state W . I did it tediously by analyzing the possible moves, and the proof is omitted here.
Now the induction step; let the statement be true for 4 j − 5 . We have to show that it is true for 4 j − 1 . Note that a nim game with initial configuration ( 1 , 2 , . . . , 4 j − 1 ) can be thought has a combination of two nim games, one with configuration ( 1 , 2 , . . . , 4 j − 5 ) , and the other with configuration ( 4 j − 4 , 4 j − 3 , 4 j − 2 , 4 j − 1 ) . Both the games are in state L . Note that unlike a simple nim game, there is a complication here. A move a player gives is either a move to the first nim game, or a move to the second nim game. But here, from the perspective of any one nim game, one player can give consecutive moves.
Now note that if a player gives two consecutive moves, the state of the game changes. So if one player wants to change the state of a game, he can do it by taking out a stone from the set where he played last. Now note that one of these games will end before another. If, at this phase, the states of these two games are different, the first player will win. If the states of these two games are same, the second player will win. However, the second player knows how to manipulate the state of each games, and after the first player has given his move, he can manipulate the state of the games so that the states of both games are equal. Hence this configuration has state L .
Similar arguments show that all other integers satisfy the given condition. The total number of these integers from 1 to 1 0 0 0 (both inclusive) is 7 5 0 . Hence, the required probability is 1 0 0 0 7 5 0 .