Thursday, August 20, 2015

MJ [19] Who wins ||-- The Game of Nim

Question:
Given n piles of coins, two player take turn to remove coins. Every pile may have any number of coins. Each time a player can remove any number of coins but only from 1 pile. The player removes the last coin wins the game and the other player loses. Determine whether the first player can win. Note that the first player loses if there is no coins at the beginning because he/she cannot remove the last coin.
==== =====
Ref
[1] https://www.topcoder.com/community/data-science/data-science-tutorials/algorithm-games/
[2] http://letuskode.blogspot.com/2014/08/grundy-numbers.html
[3] http://web.stanford.edu/class/cs97si/05-combinatorial-games.pdf

No comments:

Post a Comment