[Math] Who’s winning this coin drawing game

game theory

There are 2 piles of coins, each containing 2010 pieces. Two players A and B play a game taking turns (A plays first). In each turn the player on play has to take 1 or more coins from 1 pile or exactly 1 coin from both piles. Whoever takes the last coin is the winner. Which player will win if both play in the best possible way? We represent the present state of a game as config.(a+b) which means there are "a" coins in one pile an "b" coins in the other pile. Now it can be easily seen that a (2+1) config is a losing one for the person to play. Similarly a (3+3) config is a losing one for the person to play. Hence a (4+4) is a winning config because the player will then draw 1 coin each from both pile and force the other to a losing config. (5+5) is also a winning config because then the player to play(say A) will draw 1 coin from one of the piles. Hence depending on the other player's move it will turn into a (4+4) for A or a (3+3) for B after the next chance. So how do I proceed?

Best Answer

As Ross pointed out, you can solve this using nimbers. Working out the nimbers for some low coin counts leads to the winning strategy: Always make sure the coin counts are roughly equal, $\pm1$, and that their sum is divisible by $3$. That is, if the coin counts are equal and both have remainder $1$ mod $3$, take one coin from each pile; if the coin counts are equal and both have remainder $2$ mod $3$, take a coin from either pile: if the coin counts are different, take as many from the larger pile that you end up with the same count $\pm1$ and the sum is divisible by $3$. Such a move is always possible if the position isn't one of the losing positions $(3k,3k)$ or $(3k+1,3k+2)$ or $(3k+2,3k+1)$.

In particular, since $2010$ is divisible by $3$, the initial position is a losing position for player $A$.

Related Question