More than Nim

A two-player game is played with two piles of stones, with sizes m , n m,n . On a player's turn, that player can remove any positive integer number of stones from one pile, or the same positive integer number of stones from each pile. A player loses when they are unable to take a stone. If 1 m , n 30 1 \leq m,n \leq 30 , for how many of the 30 × 30 = 900 30 \times 30 = 900 starting positions does the first player have a winning strategy?


The answer is 878.

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.

9 solutions

Let S S be the set of nonnegative integers and v : S × S { 1 , 2 } v : S \times S \to \{1,2\} be a function from pairs ( m , n ) (m,n) to two possible values : 1 1 if player 1 1 has a winning strategy in a current state where there are m , n m,n stones in pile 1 , 2 1,2 respectively, and 2 2 otherwise.

We can represent the possible set of moves as v ( a , 0 ) = v ( 0 , a ) = v ( a , a ) = 1 v(a,0) = v(0,a) = v(a,a) = 1 for any a a . Now we want to find all ( m , n ) (m,n) such that v ( m , n ) = 2 v(m,n)=2 .

One can see for m n m \leq n (case m n m \geq n will be similar), that v ( m , n ) = 1 v(m,n) = 1 if and only if m = n m = n or m = 0 m = 0 or ( m , n ) (m,n) can be reduced to some ( p , q ) (p,q) after player 1 1 makes his move, where v ( p , q ) = 2 v(p,q) = 2 . In other words, v ( m , n ) = 2 v(m,n) = 2 if and only if v ( p , q ) = 1 v(p,q) = 1 for all possible moves of player 1 1 .

Now ,let's consider ( p , q ) (p,q) such that v ( p , q ) = 2 , p < q v(p,q)=2, p<q (if the pair exists). The necessary conditions are :

I. ( p x , q ) , x > 0 (p-x,q), x > 0 , In other words v ( a , q ) = 1 v(a,q) = 1 for all 0 a < p 0 \leq a < p

II. ( p , q x ) , x > 0 (p,q-x), x > 0 , In other words, v ( p , a ) = 1 v(p,a) = 1 for all 0 a < q 0 \leq a < q .

III. ( p x , q x ) , x > 0 (p-x,q-x), x > 0 . Note that there is an invariant on the difference of the number of stones since q p = ( q x ) ( p x ) q-p = (q-x)-(p-x) In other words, if D = q p D = q-p , then v ( a , a + D ) = 1 v(a,a+D) = 1 for all 0 b < a 0 \leq b < a .

Start with an originally empty set A A and B B . Claim that we can generate the next ( p , q ) (p,q) such that v ( p , q ) = 2 , p < q v(p,q) = 2, p<q with the following method : Find the least natural number not in A A (let's say x x ), and also the least not in B B (let's say y y ). way.

By the way, 'next' means if the previous pair such that v = 2 v = 2 is ( p , q ) (p',q') , then either p > p p > p' or p = p , q = q p = p', q = q'

The next ( p , q ) (p,q) must be ( x , x + y ) (x,x+y) (The reasons are below). Then we add x x to A A and y y to B B .

Reasons :

i) The least p p must be equal to x x . Otherwise p < x p < x and so p A p \in A . But it means that v ( p , p + d ) = 2 v(p,p+d)=2 for some d B d \in B . Since any new q q must be such that q p > d q-p > d for any d B d \in B , then the state ( p . q ) (p.q) can be reduced to ( p , p + d ) (p,p+d) , by taking q p d > 0 q-p-d > 0 stones from the 2nd pile and so v ( p , q ) = 1 v(p,q) = 1 . Hence, p = x p = x .

ii) Given p p , the least q q must be such that q p > d q-p > d for any d B d \in B (since otherwise v ( p , q ) = v ( p , p + d ) = 1 v(p,q)=v(p,p+d) = 1 for some d B d \in B as by the definition of the above's method, there is a p < p p' < p such that v ( p , p + d ) = 2 v(p',p'+d) = 2 and we can reduce get from ( p , q ) = ( p , p + d ) (p,q) = (p,p+d) to p , p + d ) p',p'+d) by taking p p > 0 p-p'>0 stones from the 1st pile. ). Hence q p = y q-p = y .

With the above's method we will get ( 1 , 2 ) , ( 3 , 5 ) , ( 4 , 7 ) , ( 6 , 10 ) , ( 8 , 13 ) , ( 9 , 15 ) , (1,2),(3,5),(4,7),(6,10),(8,13),(9,15), ( 11 , 18 ) , ( 12 , 20 ) , ( 14 , 23 ) , ( 16 , 26 ) , ( 17 , 28 ) , ( 19 , 31 ) , (11,18),(12,20),(14,23),(16,26),(17,28),(19,31),\cdots and their reverses. We stop at ( 17 , 28 ) (17,28) since the next element ( 19 , 31 ) (19,31) has its 2nd number bigger than 30 30 , We have 11 × 2 = 22 11 \times 2 = 22 pairs of ( p , q ) (p,q) such that v ( p , q ) = 2 v(p,q) = 2 (losing positions for player 1 1 ) where p , q 30 p,q \leq 30 .

Hence there are 900 22 = 878 900-22 = 878 starting positions where first player have a winning strategy.

Students had difficulty finding the losing positions because the list of positions did not have an easily recognizable pattern.

Calvin Lin Staff - 7 years ago
Thomas Beuman
Aug 13, 2013

First I will present a proof, and then an interesting feature, involving the golden ratio, that you may not have seen or known, and want to try and prove.

Since this game is impartial (i.e. both players have identical abilities), and guaranteed to finish with a victory for one of the players, it is possible to identify each possible position as being either an N-position (advantageous to the next player, i.e. winning for the player to move) or a P-position (advantageous to the previous player). From an N-position, it is possible to make a move that results in a P-position, from a P-position all moves result in an N-position. The question is thus to determine the number of N-positions.

I will use the notation ( a , b ) (a,b) , with a b a \leq b , to refer to game positions. (Note that the two piles are identical with respect to the rules of the game, so the constraint a b a \leq b is justified.) I will call a position "smaller" than another position, if it preceeds the other in lexicographical order, i.e.

( a , b ) < ( c , d ) a < b or ( a = b and c < d ) (a,b) < (c,d) \iff a<b \text{ or (} a=b \text{ and } c<d \text{)}

The point is that any move will always result in a smaller position. This ordering therefore provides a way to work bottom-up. With all that set up, we can get to work.

First of all, ( 0 , 0 ) (0,0) is obviously a P-position. Therefore, all positions of the form ( 0 , n ) (0,n) or ( n , n ) (n,n) , with n > 0 n>0 , are N-positions, since the player to move can reach the P-position in one go. The smallest position from which it is not possible to reach ( 0 , 0 ) (0,0) is ( 1 , 2 ) (1,2) , which we can thus identify as a P-position. Now we find that all positions ( 1 , n ) (1,n) , ( 2 , n ) (2,n) and ( n 1 , n ) (n-1,n) with n > 2 n>2 are N-positions, since the player to move can reach ( 1 , 2 ) (1,2) . The smallest position that does not belong to any of these is ( 3 , 5 ) (3,5) . Again, it is a P-position. The next one you'll find is ( 4 , 7 ) (4,7) . The generalization might be obvious by now, but I'll prove it rigorously.

In general, the n n -th P-position (starting from P 0 = ( 0 , 0 ) P_0 = (0,0) ) is P n = ( a n , b n ) P_n = (a_n, b_n) , where a n a_n is the smallest integer x > a n 1 x > a_{n-1} with x b k x \neq b_k for all k < n k<n , and b n = a n + n b_n = a_n+n . To prove this, we need to establish that this conforms to the properties of P-positions and N-positions given above.

First we demonstrate that from any P-position P i P_i it is impossible to move to another P-position P j P_j (with i > j i > j ). If it were possible, we would need to have a i = a j a_i = a_j , b i = b j b_i = b_j , a i = b j a_i = b_j , b i = a j b_i = a_j or b i a i = b j a j b_i - a_i = b_j - a_j . All of these trivially cannot be true based on the definition above (the second for instance follows from b i = a i + i > a j + i > a j + j = b j b_i = a_i + i > a_j + i > a_j + j = b_j ).

Now to demonstrate that from any N-position ( x , y ) (x,y) one can move to a P-position. We can distinguish the following cases ( k k is always some integer):

  • x = a k , y > b k x = a_k, y > b_k : one can move to P k P_k by reducing y y to b k b_k
  • x = a k , y < b k x = a_k, y < b_k : one can move to P y x P_{y-x} by reducing both piles (note that y x < k y-x < k )
  • x = b k x = b_k : one can move to P k P_k by reducing y y to a k a_k (note that y x > a k y \geq x > a_k )
  • x a i , x b i x \neq a_i, x \neq b_i for all i i : this is impossible based on the definition of a n a_n : it is always the smallest "unused" number, so all numbers are "used" eventually.

This concludes the proof.

The algorithm for determining the P i P_i 's can be easily applied to identify all P-positions (excluding ( 0 , 0 ) (0,0) ) for piles of at most 30 stones:

( 1 , 2 ) , ( 3 , 5 ) , ( 4 , 7 ) , ( 6 , 10 ) , ( 8 , 13 ) , ( 9 , 15 ) , ( 11 , 18 ) , ( 12 , 20 ) , ( 14 , 23 ) , ( 16 , 25 ) , ( 17 , 28 ) (1,2), (3,5), (4,7), (6,10), (8,13), (9,15), \\ (11,18), (12,20), (14,23), (16,25), (17,28)

There are thus 11 P-positions. Remember though that we asserted a b a \leq b , so without this constraint there are 22. The number of N-positions is therefore 900 22 = 878 900 - 22 = \boxed{878}

Now for an interesting feature: the n n -th P-position is given by

P n = ( n ϕ , n ( ϕ + 1 ) ) P_n = (\lfloor n\phi \rfloor, \lfloor n(\phi+1) \rfloor) ,

where x \lfloor x \rfloor is the floor of x x , i.e. the largest integer smaller than or equal to x x , and ϕ \phi is the golden ratio: ϕ = 1 2 ( 1 + 5 ) = 1.618 \phi = \frac12(1+\sqrt5) = 1.618\ldots

Therefore, the general answer to this problem (replacing 30 with N N ), is

N 2 2 N + 1 ϕ + 1 \boxed{ N^2 - 2\lfloor \frac{N+1}{\phi+1} \rfloor }

I happened to have heard of this game before, I don't know its name, but I remember this remarkable feature. I might present a proof later as a comment to this post, but I'll gladly let someone beat me to it.

Thanks for the observation about the game: I had spotted the Fibonacci pairs ( ( 1 , 2 ) , ( 3 , 5 ) , ( 8 , 13 ) , ) (1,2),(3,5),(8,13),\dots) but would not have got the general formula without your hint.

I'll sketch a proof which may not be the most efficient but which I think is sound. Apologies that it is a bit tricky to write-out.

First of all we can use the Fibonacci Numbers to represent all integers as sequence of zeroes and ones (like binary). For example 101001 101001 represents 1 + 5 + 8 + 13 1+5+8+13 . N.B. we can chose to always write numbers without adjacent 1's since by the Fibonacci Relation successive ones as that would give the next Fibonacci number e.g. 1100 = 3 + 5 = 8 1100=3+5=8 could be written 10000 10000 .

Let us consider the set of all numbers, O O which have their final 1 at an odd number of places from the end of their Fibonacci Representation. This means the final 1 is in the 1 , 3 , 8 , 21 1,3,8,21\dots position, i.e. 1 , 100 , 101 , 1001 , 10000 , 10001 1,100,101,1001,10000,10001\dots are the first numbers in O O The remaining Natural Numbers, E E , with their final 1 at even number of places from the end can be formed by adding a terminal zero to numbers in O O . This generates the following pairs L L : ( 1 , 10 ) , ( 100 , 1000 ) , ( 101 , 1010 ) , ( 1001 , 10010 ) (1,10),(100,1000),(101,1010),(1001,10010)\dots . In decimal these correspond to ( 1 , 2 ) , ( 3 , 5 ) , ( 6 , 10 ) , ( 9 , 15 (1,2),(3,5),(6,10),(9,15 ).

These turn out to be the losing pairs, and their relationship with the Fibonacci numbers implies the result about ϕ \phi . To prove this all we need to show is that the gaps are all different (the pairs are clearly disjoint.)

Using the Fibonacci Relation we can see that when we subtract corresponding elements of O O from those in E E the result is to shift all the 1's right, except for the final 1 which stays put. For example 100101 100101 moves to 10011 10011 which in decimal corresponds to 17 moving to 11. [N.B. This example corresponds to the fact that 17 is the first element of the \(11^{th}/) losing pair.]

To reverse the process we write a Natural Number in Fibonacci Form with either the final 1 either at the end, or at an even number of steps from the end (rewriting with a pair of 1's at the end off necessary) and then shift all the 1's left, except for a 1 at the final position which is left alone. For example 9 which can be expressed as \(10001\) maps to 100001 100001 which represents 14. [N.B. This example corresponds to the 9 t h 9^{th} losing pair starting with 14 14 . I'll omit the details but we can show that using this map each Natural Number maps to different number in E E .

All we are left to do is establish that the n t h n^{th} term is ϕ \phi . I'll leave out the details but intuitively when we shift the Fibonacci numbers in the representation of n n we approximately multiply by ϕ \phi . The way we define the map ensures that we get an underestimate. N.B. the ratio of terms within losing pairs is approximately ϕ \phi (always slightly greater).

I really enjoyed figuring this out: writing up was tricky, but once you play around with addition/subtraction in the Fibonacci bases (which is very similar to binary, just a different carrying rule) it should make sense. Would be interested to see different approaches.

My way explains various features, for sample the fact of why you can always subtract the largest possible pair of Fibonacci Numbers from losing pairs to still get a losing pair (e.g. ( 12 , 20 ) ( 8 , 13 ) ) = ( 4 , 7 ) (12,20)-(8,13))=(4,7) , and of course why you get Fibonacci Pairs at alternate Fibonacci positions e.g. ( 21 , 34 ) (21,34) at position 13 13 .

David Vaccaro - 7 years, 10 months ago

One small correction: If the game begins with (16,25), the first player can remove two from each pile.

Peter Byers - 4 years, 8 months ago
Matt McNabb
Aug 12, 2013

The complete list of losing positions is: L 1 = ( 1 , 2 ) L 2 = ( 3 , 5 ) L 3 = ( 4 , 7 ) L 4 = ( 6 , 10 ) L 5 = ( 8 , 13 ) L 6 = ( 9 , 15 ) L 7 = ( 11 , 18 ) L 8 = ( 12 , 20 ) L 9 = ( 14 , 23 ) L 10 = ( 16 , 26 ) L 11 = ( 17 , 28 ) \begin{aligned} L_1 &= (1, 2) \\ L_2 &= (3, 5) \\ L_3 &= (4, 7) \\ L_4 &= (6, 10) \\ L_5 &= (8, 13) \\ L_6 &= (9, 15) \\ L_7 &= (11, 18) \\ L_8 &= (12, 20) \\ L_9 &= (14, 23) \\ L_{10} &= (16, 26) \\ L_{11} &= (17, 28) \end{aligned} plus their reverses ( 2 , 1 ) (2, 1) , ( 5 , 3 ) (5, 3) , etc.

Proof: Let L = { L k , (and their reverses) } L = \left\{ L_{k}, \text{(and their reverses)} \right\} be the set of positions listed above, and W W be the other positions. We will show that:

Case 1: If a position is in L L then there is no move that leaves another position in L L

Case 2: If a position is in W W then there is always a move that takes all stones, or leaves a position in L L

This will prove that all positions in L L are losing, and all positions in W W are winning.

Note - the winning condition "a player is unable to take a stone" can only happen if there are no stones (since taking one stone is a legal move), therefore a player wins if he takes the last remaining stone.

In the cases below we assume without loss of generality that the position ( m , n ) (m, n) has m n m \leq n .

Case 1: No position in L L has a pile with the same number of stones as any other position in L L , therefore the move "take stones from one pile" cannot leave a position in L L .

Further, each position L k = ( m , m + k ) L_k = (m, m + k) . So the move "Remove k stones from each pile" cannot leave a position in L L , since the value of k k is different for each of these members.

Case 2: (i) : If the position is ( m , m ) (m, m) then the move "take m m stones from each pile" wins.

(ii) : If the position is ( m , m + k ) (m, m+k) then we have sub-cases:

(a): If there exists L q = ( m , m + q ) L_q = (m, m+q) and k > q k > q then the move "take k q k - q stones from the second pile" leaves L q L_q . Or if q > k q \gt k , then the move "remove m l m - l stones from each pile" leaves L k = ( l , l + k ) L_k = (l, l + k) . This works because the sizes of piles in L q L_q are greater than those in L k L_k whenever q > k q \gt k .

(b): If there exists L q = ( m q , m ) L_q = (m - q, m) then the move "take k + q k + q stones from the second pile" leaves the reverse of L q L_q . We clearly must have m + k > m q m+k \gt m-q ..

Since all values from 1 1 through 18 18 appear in a member of L L , those two cases are exhaustive for m < 19 m \lt 19 . So we have remaining:

(c): If m 19 m \ge 19 we must have k 11 k \le 11 because of the stipulation of 30 30 being the maximum pile size. In this case, the move "remove m l m - l stones from each pile" leaves L k = ( l , l + k ) L_k = (l, l + k) .

Conclusion: there are 22 22 losing positions in L L : the 11 11 listed above, and their reverses. So the number of winning positions is 900 22 900 - 22 = 878 \boxed{878} .

Examples: ( 9 , 12 ) (9,12) wins by case 2(ii)(a) with k = 3 k = 3 , q = 6 q = 6 ; we remove 5 5 stones from each pile to leave L 3 = ( 4 , 7 ) L_3 = (4, 7) .

( 9 , 22 ) (9, 22) wins by case 2(ii)(a) with k = 13 k = 13 , q = 6 q = 6 ; we remove 7 7 stones from the second pile to leave L 6 = ( 9 , 15 ) L_6 = (9, 15) .

( 24 , 26 ) (24, 26) wins by case 2(ii)(c) , we remove 21 21 stones to leave L 2 = ( 3 , 5 ) L_2 = (3, 5) .

The game's called Wythoff's game . The complete solution is given here .

C Lim - 7 years, 10 months ago

Just noticed that I omitted to prove that L 1 L_1 is a losing position. This can be done by considering L 0 = ( 0 , 0 ) L_0 = (0, 0) and applying the same logic as Case 1. But we don't count L 0 L_0 in the final reckoning as it's not a valid start position.

I also glossed over positions that feature piles of size 0 - these should be included in W W , and the winning move is "remove all stones from the non-zero pile".

Matt McNabb - 7 years, 10 months ago

The algorithm to generate the L L list is as follows:

L 1 = ( 1 , 2 ) L_1 = (1, 2) is the smallest losing position, by inspection.

Any position ( 1 , n ) (1,n) , ( 2 , n ) (2,n) , or ( n , n + 1 ) (n, n+1) now is winning because it can be reduced to L 1 L_1 . The next losing position must be the one that does not fit in any of those categories, but all possible moves reduce it to a position already considered. That is, L k = ( l = L_k = (l = smallest number that does not yet appear , l + k ) , l + k) .

Matt McNabb - 7 years, 10 months ago
Kai Chung Tam
May 20, 2014

Within the 900 starting positions, there are 22 of them at which the second player has a winning strategy. (We will also refer this kind of positions as sure-lose positions . The positions such that the first player has a winning strategy are called sure-win positions ). Eleven of these sure-lose positions are:

( 1 , 2 ) , ( 3 , 5 ) , ( 4 , 7 ) , ( 6 , 10 ) , ( 8 , 13 ) , ( 9 , 15 ) , (1,2), (3,5), (4,7), (6,10), (8,13), (9,15), ( 11 , 18 ) , ( 12 , 20 ) , ( 14 , 23 ) , ( 16 , 26 ) , ( 17 , 28 ) , (11,18), (12, 20), (14,23), (16,26), (17,28),

and the other eleven losing positions are just the "reverse" of them, namely, ( 2 , 1 ) , ( 5 , 3 ) , , ( 28 , 17 ) (2,1), (5,3), \cdots, (28,17) .

Since the game does not allow a draw, and it is terminating in a finite number of steps, the total number of sure-win and sure-lose positions is 900, therefore the number of sure-win is 900-22= 878 .

To see how we can get the list of sure-lose positions, one way is to use a tabular (or lattice) representation. Consider the set of coordinates { ( m , n ) : m = 0 , 1 , 30 ; n = 0 , 1 , 30 } \{(m,n): m=0, 1, \dots 30; n=0, 1, \dots 30\} , and we assign to each pair ( m , n ) (m,n) a number S ( m , n ) { 0 , 1 } S(m,n)\in \{0,1\} , where S ( m , n ) = 1 S(m,n) = 1 if and only if it is a sure-win position (therefore S ( m , n ) = 0 S(m,n)=0 if it is a sure-lose position).

We observe the following: - S ( 0 , 0 ) = 0 S(0,0)=0 , since if on a player's turn there is no stone in both piles, the player loses by definition. - If S ( m , n ) = 0 S(m,n) = 0 then S ( m , n + x ) = S ( m + x , n ) = S ( m + x , n + x ) = 1 S(m,n+x)=S(m+x,n)=S(m+x,n+x)=1 for all x > 0 x>0 because the first player can remove x x stones from either or both of the piles. So now we know that S ( 0 , x ) = S ( x , 0 ) = S ( x , x ) = 1 S(0,x)=S(x,0)=S(x,x)=1 for all x > 0 x>0 (Draw a picture to see it :-) - S ( m , n ) = 0 S(m,n)=0 if and only if S ( m , n x ) = S ( m x , n ) = S ( m x , n x ) = 1 S(m,n-x)=S(m-x,n)=S(m-x,n-x)=1 for all admissible x > 0 x>0 . This is because a position is sure-lose when all of the possible moves give a sure-win position to its opponent! For example, S ( 1 , 2 ) = 0 S(1,2)=0 because S ( 0 , 2 ) = S ( 1 , 1 ) = S ( 1 , 0 ) = S ( 0 , 1 ) = 1 S(0,2)=S(1,1)=S(1,0)=S(0,1)=1 . - Similarly, S ( 2 , 1 ) = 0 S(2,1)=0 . Then one also knows that S ( 2 + x , 1 ) = S ( 2 , 1 + x ) = S ( 2 + x , 1 + x ) = 1 S(2+x,1)=S(2,1+x)=S(2+x,1+x)=1 for all x > 0 x>0 . Again, please draw a picture in order to help our eyes to see the pattern.

Since there are only 31 rows and 31 columns, it is not hard to continue the observation above even if we don't generalize. Thus we get the 22 sure-lose positions mentioned above.

Some notes:

  1. One can simplify the process above by noticing that the difference of the coordinates of the sure-lose positions are 0 , 1 , 2 , 3 , 0, 1, 2, 3, \dots . For example, the first one is ( 0 , 0 ) (0,0) with 0 0 = 0 0-0=0 , the second (pair) is ( 1 , 2 ) , ( 2 , 1 ) (1,2), (2,1) , with |2-1|=1. The n n -th pair is determined by the following algorithm: take the smallest positive integer a n a_n that has not been used in the previous pairs, then the new pair is ( a n + n , a n ) , ( a n , a n + n ) (a_n+n,a_n), (a_n,a_n+n) . For example, a 2 = 3 a_2 = 3 , so the second pair is ( 3 , 5 ) , ( 5 , 3 ) (3,5),(5,3) . Then a 3 = 4 a_3=4 , so the third pair is ( 4 , 7 ) , ( 7 , 4 ) (4,7),(7,4) , and so forth.

  2. A more efficient algorithm to calculate a n a_n is the integer part of

n 5 + 1 2 n\cdot \frac{\sqrt{5}+1}{2} . (Verify it!)

No real justification for most of the arguments.

Calvin Lin Staff - 7 years ago
Victor Wang
May 20, 2014

We work backwards to find all losing positions with m n m \le n . The key is that if ( x , y ) (x,y) is winning iff there exists k 1 k\ge1 such that one of ( x k , y k ) (x-k,y-k) , ( x , y k ) (x,y-k) , and ( x k , y ) (x-k,y) is losing.

For m = 0 m = 0 , ( 0 , 0 ) (0,0) is losing, so ( 0 , n ) (0,n) is clearly winning for n 1 n \ge 1 .

For m = 1 m=1 , ( 1 , 1 ) (1,1) is winning, so ( 1 , 2 ) (1,2) is losing and ( 1 , n ) (1,n) is winning for n 3 n\ge3 .

For m = 2 m=2 , ( 2 , n ) (2,n) is winning for all n 2 n\ge2 , since ( 2 , 1 ) (2,1) is losing.

In general, it's easy to see that for fixed m m , there exists at most one value of n n such that ( m , n ) (m,n) is losing. Now order the losing pairs as ( m 0 , n 0 ) , ( m 1 , n 1 ) , (m_0,n_0),(m_1,n_1),\ldots with m i n i m_i \le n_i and m 0 < m 1 < m_0 < m_1 < \cdots , starting with ( m 0 , n 0 ) = ( 0 , 0 ) (m_0,n_0) = (0,0) . A simple induction on i i shows that ( m i , n i ) (m_i,n_i) exists with n i m i = i n_i - m_i = i and m i m_i the least integer not in the set { m 0 , n 0 , , m i 1 , n i 1 } \{m_0,n_0,\ldots,m_{i-1},n_{i-1}\} . Indeed, m i m_i cannot lie in the set or else two losing pairs would intersect. On the other hand, if it is the smallest integer not in the set, then ( m i , m i ) , , ( m i , m i + i 1 ) (m_i,m_i),\ldots,(m_i,m_i+i-1) must all be winning by the inductive hypothesis, while ( m i , m i + i ) (m_i,m_i+i) is losing since the differences i , i + 1 , i + 2 , i,i+1,i+2,\ldots do not belong to any losing pairs with smaller sum of coordinates and m i m_i is too large to be in a smaller (previous) losing pair by construction.

It follows that ( 1 , 2 ) , ( 3 , 5 ) , ( 4 , 7 ) , ( 6 , 10 ) , ( 8 , 13 ) , ( 9 , 15 ) , ( 11 , 18 ) , ( 12 , 20 ) , ( 14 , 23 ) , ( 16 , 26 ) , ( 17 , 28 ) (1,2),(3,5),(4,7),(6,10),(8,13),(9,15),(11,18),(12,20),(14,23),(16,26),(17,28) are the 11 11 losing pairs with both terms at most 30 30 , so the answer is 3 0 2 2 11 = 878 30^2 - 2\cdot 11 = 878 .

Justification needs more work.

Calvin Lin Staff - 7 years ago
Zi Song Yeoh
May 20, 2014

Denote the position where there are a stones in the first pike and b n the second pile by (a,b). We consider the case a < b, and the case a > b follows analogously. Note that (a,a), (a,0), (0,a) are winning positions for player 1. So this settles the case a = b.

First, we claim that (1,2) is a losing position for P1. Since P1 can only transform it into a winning position for P2, ((1,1),(1,0),(0,1),(0,2)), P1 loses. Then (m,m + 1) is a winning position for P1 where m > 1 since P1 can transform it into (1,2). Now consider (m, m + 2). (1,3), (2,4) are winning positions (can be transformed into (1,2) or (2,1)), and (3,5) isn't, since Move 1 can only transform one of the piles into less than 3 stones, with the other having 5, which is a winning position, or transform it into (m, m + 1), (m,m) , (m+1,m) or the previous case, and with m > 1. So P1 loses, (3, 5) is a losing position.

Continuing similarly, we can find that (4,7), (6,10), (8, 13), (9, 15), (11, 18), (12, 20), (14, 23), (16, 26), (17, 28). So there are a total of 11 losing positions in this case. If a > b, there are 11 losing positions too (namely (2,1), (5,3), etc...). So there are a total of 900 - 22 = 878 \boxed{878} winning positions.

"Continuing similarly" portion needs to be explained more.

Calvin Lin Staff - 7 years ago
David Vaccaro
Aug 13, 2013

Let us represent a position with m m stones in one pile, and n n stones in the other pile, with m n m\leq n as the pair ( m , n ) (m,n) .

First of all I will define a sequence of pairs (which will turn out to be the losing positions). We start with a 0 = 0 , b 0 = 0 a_{0}=0, b_{0}=0 and then define recursively:

  • a n a_{n} is the smallest number not in either sequence ( a 0 , a 1 , , a n 1 ) , ( b 0 , b 1 , , b n 1 ) (a_{0},a_{1},\dots, a_{n-1}), (b_{0},b_{1},\dots, b_{n-1})
  • b n = a n + n b_{n}=a_{n}+n

This generates the set of pairs L L : ( 0 , 0 ) , ( 1 , 2 ) , ( 3 , 5 ) , ( 4 , 7 ) , ( 6 , 10 ) , ( 8 , 13 ) (0,0),(1,2),(3,5),(4,7),(6,10),(8,13) ( 9 , 15 ) , ( 11 , 18 ) , ( 12 , 20 ) , ( 14 , 23 ) , ( 16 , 26 ) , ( 17 , 28 ) , ( 19 , 31 ) (9,15),(11,18),(12,20),(14,23),(16,26),(17,28),(19,31)\dots .

Firstly, it is clear that any move from L L takes you out of L L . This is because the pairs in L L have disjoint elements (since a n a_{n} and b n b_{n} are disjoint and monotone increasing) and have different gaps (the sequence of gaps is just ( 0 , 1 , 2 , 3 , ) (0, 1,2,3,\dots) ).

Secondly, let us show that if we start at a position ( α , β ) (\alpha,\beta) not in L L with α β \alpha\leq \beta then you can always find a move into a position in L L .

Note that every number will eventually feature in the sequence L L . Defining a n a_{n} as the smallest non-included number ensures there are no gaps. We must then have that α \alpha features in either the sequence of a a 's or b b 's, and we can consider these two cases separately.

  • If α \alpha is one of the a a s, say α = a n \alpha = a_{n} then there are two possibilities if β < b n \beta< b_{n} then the gap between them, k k , is smaller than n n and by removing the same amount of stones ( a n a k a_{n}-a_{k} ) from each pile we can reduce to ( a k , b k ) (a_{k},b_{k}) . If β > b n \beta> b_{n} then we can just remove β b n \beta-b_{n} ) stones from the β \beta pile to reduce to ( ( a n , b n ) ((a_{n},b_{n}) .

  • If α \alpha is one of the b b 's, say α = b n \alpha= b_{n} then we can just remove stones from the β \beta pile (noting that a n < b n = α β a_{n} < b_{n}= \alpha \leq \beta ) to get to ( a n , b n ) (a_{n},b_{n}) .

We now can define a very simple winning strategy for Player 1 for all starting positions not in L L . All he needs to do is move in such a way that after each of his move Player 2 is confronted with a position in L L . We have shown both that this is possible on the first move, and since Player 2 cannot return a position in L L It will also be possible on subsequent moves. Of course if Player 1 starts with a position of L L then he is forced to move out of L L , and player 2 can reproduce player 1's winning strategy.

We now know that any position in L L loses and all other position win. There are 11 elements of L L with piles of size between 1 and 30 or fewer (i.e. ( 0 , 0 ) (0,0) and ( 19 , 31 ) (19,31) and onward are outside the range ) each contributing two orders (e.g (1,2) could be m = 1 , n = 2 m=1, n=2 or m = 2 , n = 1 m=2, n=1 . Hence there are 22 losing positions from the 900 starting positions, leaving 878 winning positions.

黎 李
May 20, 2014

(1,2) (3,5) (4,7) (6,10) (8,13) (9,15) (11,18) (12,20) (14,23) (16,26) (17,28)

Not a proof

Calvin Lin Staff - 7 years ago
Brick Stone
May 20, 2014

Let (m,n) represent the configuration with m stones in pile 1 and n stones in pile 2. Let (m,n) be a WC (winning configuration) for player x (pX) if pX has a winning strategy for (m,n) Note that when m=n, p1 wins. If (m,n) is a WC for p2, note that for all (m,k), k > n, p1 can win by using his first move to reduce k to n. This is derived from p1's ability to remove stones from the pile with n stones Similarly, for (r,n), r > m, p1 will win. Lastly, for (m+q,n+q), q > 0, player 1 will be able to remove q stones from both piles and win. Note that (1,2) is a WC for p2. By continuing on, we find that (1,2), (3,5), (4,7), (6,10), (8,13), (9,16), (11,19), (12,21), (14,24), (15,26) and (17,29) [and the other order] are the only WC for p2. Hence, WC for p1 = 900 - 2*11 = 878

"by continuing on" doesn't really mean anything. Nothing was actually proved here.

Calvin Lin Staff - 7 years ago

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...