Monday, April 5, 2021

Never go up against the game's creator, when pennies are on the line!

You and Wenjun are playing a game in which you alternate taking turns, removing pennies from a pile. On your turn, you can remove either one or two pennies from the pile. On Wenjun’s turn, he can remove either two or three pennies. Whoever takes the last penny loses. (If there is only one penny left and it’s Wenjun’s turn, then he skips his turn, which means you will lose). Suppose both you and Wenjun play optimally.

1) If you go first, then what initial numbers of pennies mean you will win the game?

2) If Wenjun goes first, then what initial numbers of pennies mean he will win the game?

Let $N$ be the number of initial pennies.

First, let's see that no matter who goes first, if there are $N=2$ initial pennies, the person who goes first will lose. (If Wenjun goes first, he must remove both of the pennies and loses right away. If I go first, then either I remove both of the pennies and lose right away or I can delay the inevitable by only removing one penny, but as per the note above then I will lose when Wenjun skips his turn.)

Similarly, if $N=1$, then I will lose regardless of who goes first, since Wenjun given himself the super power of being able to skip his turn in this case.

The losing behavior has a period of $4$ in the initial number of pennies. Let's say I go first, then regardless of my move, Wenjun can make a corresponding move to ensure that I am left with $N-4$ pennies to make my next move. Similarly, if Wenjun goes first, I can also make a corresponding move to make sure that his next move will be with a pile of $N-4$ pennies.

So for instance, since I will lose if I go first with $N \in \{1,2\},$ then I will in face lose whenever $N \in \{1,2\} + 4\mathbb{N}.$ To confirm that these are the only times I can lose, let's look at the converse. If $N \in 3 + 4\mathbb{N}$ then my first move should be to remove $1$ penny, so that Wenjun will start with a pile of pennies whose size is in $2 + 4\mathbb{N}.$ Similarly, if $N \in 4\mathbb{N}$ then my first move would be to remove $2$ pennies, again leaving Wenjun with a losing pile of pennies with size in $2 + 4\mathbb{N}.$ So if I go first, I will win whenever the initial size $N \in \{3,4\} + 4\mathbb{N}.$

Wenjun's advantage is that I lose whenever I start with a pile with since in $\{1,2\} + 4\mathbb{N}.$ To see this, if $N \in 1 + 4\mathbb{N},$ he will leave me with a pile with size in $2 + 4\mathbb{N}$ if he removes $3$ pennies with his first move. If $N \in \{3,4\} + 4 \mathbb{N}$ then he will leave me with a pile in $\{1,2\} + 4\mathbb{N}$ by removing $2$ pennies. So if Wenjun goes first, he will whenever the initial size $N \in \{1,3,4\} + 4\mathbb{N}.$

It just goes to show, that you should always be wary when quantum computing whiz kids propose that you play a mathematical game. Especially if they go first!

No comments:

Post a Comment