A two player match picking game from the Moscow Puzzles book This is Problem $286$, An Even Number Wins, from the book The Moscow Puzzles by Boris A. Kordemsky.

Two players take turns to pick up from a pile of $27$ matches anywhere between $1$ and $4$ of the matches until the pile is empty. You are the first player. To win, you must have an even number of matches at the end. How do you win this game?


The book has the following solution at the end. I am seeking a proof to it.

Take 2 matches and then:
If your opponent takes an even number of matches, leave him a number that is larger by $1$ than a multiple of $6$ (i.e. $19, 13, 7$).
If he takes an odd number, leave him a number that is smaller by $1$ than a multiple of $6$ (i.e. $23, 17, 11, 5$).
If this is impossible, leave him a number that is a multiple of $6$ (i.e. $24, 18, 12, 6$). For example, you take $2$ and he takes $3$, leaving $22$.  You can't take $5$ (leaving $17$), so you take $4$ (leaving $18$).


Epilogue: I realize now that I misread the problem. I took the winning condition to be picking up an even number of matches at one's last turn which would have made the question ill-defined. That was why I thought the question was ambiguous and could not understand the solution in the book as quoted above.
 A: To analyse the game, for each $n$ we need to examine two cases: I am next to play with an even number of matched in hand, and I am next to play with an odd number of matches in hand.
If there is $1$ match, I must take it and end the game. I win if I started with odd and lose if I started with even.
If there are $2$ matches and I have odd, I take $1$, and if I have even, I take $2$. Therefore no good move leaves a pile of $2$ for my opponent.
If there are three matches and I have odd, I take all three. If I have even I take $2$ and win. Therefore no good move leaves a pile of three matches.
Suppose I face a pile of $4$. With even I take $4$ and win. With odd, I take $3$ and win. No good move leaves a pile of four.
So I and my opponent are both avoiding leaving piles of size $2,3,4$.
With a pile of $5$ in front of me, therefore, my only possible good move is to take $4$ and leave a pile of $1$ and this can only win if I have an even number already.
With a pile of $6$, my only possible good move is to a pile of $5$ (take $1$) and this wins if my opponent has an odd number (they's win from $5$ if they had even). That means (since the starting number is odd) that I must have an even number.
Tabulating my wins
$1: O$
$2: OE$
$3: OE$
$4: OE$
$5: E$
$6: E$
With $7$ on the table, my opponent wins with even, whatever I do. And if opponent has odd, so do I:
$7: O$
Now with $8$ or $9$ or $10$ I can play to $6$ or $7$ depending whether my opponent has odd or even and win either way:
$8, 9, 10: OE$
So there are another three numbers I cannot afford to leave. My only possible move from $11$ is to $7$ and this only works if my opponent has even, and I therefore have even. And the pattern continues.
