Friday, March 23, 2012

N Stone game.


There are N stones in front of you. You and your opponent have to play a game. Anyone who plays next can take 1 or 2 stones from the pile of stones and leave the rest of the pile to be taken by the next guy. Whoever picks the last stone wins according to the rule. You are allowed to choose whether you should start the game or the other guy should start. How will you make a winning strategy out of it such that you always win the game.


If Number of Stone is multiple of 3 opponent should play first...else you should play first..
If you are playing then you should make sure that after your pickup the number of stone left is multiple of 3


Lets trace:
*Y = you
*O = Other


Stones
1 - (Y)
1 1 - (Y)
1 1 1 - (O)
1 1 1 1 - (Y)
1 1 1 1 1 - (Y)
1 1 1 1 1 1 - (O)
1 1 1 1 1 1 1 - (Y)
1 1 1 1 1 1 1 1 - (Y)
1 1 1 1 1 1 1 1 1 - (O)

No comments:

Post a Comment