# Thread: if i have any number N how can i know who win if two players play optimally.

1. ## if i have any number N how can i know who win if two players play optimally.

here is the problem statment :
There is a game played by two players called “One Two”. The first player starts the game and choose either 1 or 2 then the second player chooses to add 1 or 2 to the number the first player chose. then the first player choose to add 1 or 2 to the resulting value from the previous two turns and so on. The player that reaches N first wins.
For example if N = 5 and the first player chooses 2 (Sum so far = 2) then the second player
chooses 1 (Sum so far = 3) then the first player chooses 2 (Sum so far = 5) then the first player
wins this game as he is the one who reached 5.

so if i have any number N how can i know who win if two players play optimally???!!!

2. ## Re: can u help me !!!

hi mido22

here are the cases:
1.N is divisible by 3:
player two has the winning strategy.
in this case whatever player one choses the player two can choose the opposite and by doing that the sum after his turn and only after his turn will always be divisible by 3.

2.N gives remainder 1 when divided by 3:
player one has the winning strategy.
in this case player one should start with 1 then choose the opposite of whatever player two chooses.doing this the sum after his turn and only after his turn will give remainder 1 when divided by 3.

3.N gives remainder 2 when divided by 3:
player one has the winning strategy.
in this case plyer one should start with 2 then choose the opposite of whatever player two chooses.doing this the sum after his turn and only after his turn will give remainder 2 when divided by 3.