How to solve this variation of nim that has division?

145 Views Asked by At

I ran into this problem, that consist of two stacks of coins each with different amount of coins, there are two players p1 and p2. p1 plays first and each take one turn.

The turn consist of removing a number from one of the stacks(it can't be less than or equal to zero) and in normal circumstances you can just use the typical rule of nim to make p1 win unless p1 has no other choice.

The catch here is that you can only remove a number from a pile if the amount in the other stack divides that number that you want to remove.

The player that takes the last coin from the stack wins. We can get really big numbers like 100000000. A case of this game would be:

7 3 here p1 wins but in

6 4 p2 wins and in

155 47 p1 wins

Can anyone help in guiding me in the right direction?