# A question on gaming theory with variables [closed]

We have two stacks of coins, each with a and b coins respectively. On each step, the player is allowed to remove as many coins as they want(but at least one) from either of the two stacks he wants to (but only from one stack). The player which can't make a move loses. Find the person which strategically has won. The question above has me baffeled. I have solved similar questions in the past, but this is the first time I am coming across one with variables inside it.

## closed as off-topic by user21820, RRL, TheSimpliFire, Xander Henderson, José Carlos SantosMay 6 at 21:37

This question appears to be off-topic. The users who voted to close gave this specific reason:

• "This question is missing context or other details: Please provide additional context, which ideally explains why the question is relevant to you and our community. Some forms of context include: background and motivation, relevant definitions, source, possible strategies, your current progress, why the question is interesting or important, etc." – user21820, RRL, TheSimpliFire, Xander Henderson, José Carlos Santos
If this question can be reworded to fit the rules in the help center, please edit the question.

• Take a look at en.wikipedia.org/wiki/Nim – Greg Martin Apr 11 at 17:15
• I am sorry but I haven't understood how to use tha in my question – kenith Apr 11 at 17:18

I can understand that the general Nim game page as given in a comment can be overwhelming. For 2 stacks, the answer can be stated simply

A player 'on the move' will lose (on optimal play of opponent), if the number of coins in the stacks are equal.

If the number of coins on the stacks is both $$0$$, that is obvious, they cannot make a move. Otherwise, they make a move that changes one stack to a stack with a smaller number of coins. Then their opponent can 'mirror' that move: They take the same number of coins from the other stack.

That again creates a situation where the first player is again 'on the move' and again the number of coins in the stack is equal (smaller than before). Since this can't go on indefinately, the first player will finally loose at some time later.

Now if you are the player to start the game and the number of coins in the stacks is equal, you will lose, as explained above. If they are not equal, you can make them equal: Take from the stack with more coins just as many to get the same number remaining as is in the other stack. Now your opponent is on the move, and because the number of coins in both stacks is equal, your opponent will lose, so you win!

• thanks a lot man – kenith Apr 11 at 18:15