I have a challenge: to win the game with the following rules:
- There are exactly two players and their turns alternate;
- At each turn, a player removes 1, 2, 3 or 4 counters from a pile that was initially 27 counters;
- The games ends when all counters have been removed;
- The player having an even number of counters when all the counters have been taken wins.
Who wins? What is the strategy for winning?
Describe the position of the game at any point by the pair $(n,o)$, meaning that there are $n$ counters left and the player whose turn it is to move has an odd number of counters, or $(n,e)$, meaning that there are $n$ counters left and the player whose turn it is to move has an even number of counters. We say a position is a winning position if the player whose turn it is to move can force a win no matter what his opponent does.
If you keep going like this you will find that the situation now repeats: the winning and losing positions for $n$ counters are the same as for $n-6$ counters. For example, if $n=7$ then $(n,o)$ wins and $(n,e)$ loses, same as for $n=1$; if $n=8$ then both $(n,o)$ and $(n,e)$ win, same as for $n=2$; and so on.
Therefore $n=27$, starting with an even number of counters ($0$ is even), is essentially the same as position $(3,e)$, and the first player wins by taking two counters.
The winning strategy is simply to follow the table of instructions given above. As there are really only twelve different positions going from $(1,o)$ to $(6,e)$, and three of these are losing positions so it doesn't matter what you do, there are in effect nine winning moves to be memorised. Here they are: in case you have never seen the notation, $n\,\hbox{mod}\,6$ means the remainder when $n$ is divided by $6$. The moves in brackets are alternatives but they cannot be used once you are down to the last six counters. $$\matrix{n\,\hbox{mod}\,6&0&1&2&3&4&5\cr o&\hbox{none}&1\,(2)&1&3\,(4)&3&\hbox{none}\cr e&1&\hbox{none}&2\,(3)&2&4&4\cr}$$ Probably a simple way of remembering them could be devised but I'll leave that up to you.