Nim games are two player strategy games where players take turns removing objects by some rules until none remain.
For this version, place N counters in a row numbered 1 to N.
A player's turn consists of taking either one counter or two counters from consecutive positions.
Whomever takes the last counter loses (this is called a misère game.)
If you were to play this game, for what values of N would you prefer go first and what should be your first move?
Here are all positions (winning, labeled "o" and losing, labeled "x") for N<10. All winning next moves are indicated by an underline and lead to a losing position for the opponent.
Note: for N= (1), 4, 9, the winner goes second, not first.
A general rule to win remains illusive. Extrapolating to higher N may require a recursive code....
Edited on December 17, 2021, 9:57 am