Paper-strip Game

The following game is a classic example of Combinatorial Game Theory:
Two players start with a strip of $n$ white squares and they take alternate turns.
On each turn, a player picks two contiguous white squares and paints them black.
The first player who cannot make a move loses.
$n = 1$: No valid moves, so the first player loses automatically.
$n = 2$: Only one valid move, after which the second player loses.
$n = 3$: Two valid moves, but both leave a situation where the second player loses.
$n = 4$: Three valid moves for the first player, who is able to win the game by painting the two middle squares.
$n = 5$: Four valid moves for the first player (shown below in red), but no matter what the player does, the second player (blue) wins.

So, for $1 \le n \le 5$, there are 3 values of $n$ for which the first player can force a win.
Similarly, for $1 \le n \le 50$, there are 40 values of $n$ for which the first player can force a win.
For $1 \le n \le 1 000 000$, how many values of $n$ are there for which the first player can force a win?

This game belongs to a class of combinatorial game theory problems where there’s an optimal strategy to determine which player can force a win.

First, let’s consider the basics of the game. Two players are painting two continuous white squares in black successively. So, the number of white squares n should be even for first player to make a move otherwise he’ll automatically lose the game.

Next let’s think of a strategy for the first player to win. If the initial state of the game (i.e., number of squares) is such that he leaves an even number of unmarked squares after every turn, he can ensure his victory because he will always be able to make the last move (since only an even number of squares can be marked in each turn).

This means that all even numbers of squares are winning states for the first player.

However, we need to be careful of a few exceptions which arise due to the initial “drawback” position of a 3-square long chunk. Indeed, even if the first player has the strategy of always leaving an even number of squares, whenever he faces a 3-square long chunk of white squares, he will lose in the next turn because whatever move he makes leaves 1 white square, which combined with the next chunks of white squares will result in an odd number of white squares for the next turn of the second player, who then can use the same “always leave an even number of squares” strategy to win.

Given the drawback position of a 3-long chunk, the exceptions to the “winnable game with even number” rule are 3+2x where x is a positive integer. This is because such states can be decomposed into at least one 3-long chunk and even number of 2-long chunks. Also, the first player will lose if the initial state is 3, because whatever move he makes leaves 1 square.

In the range 1 ≤ n ≤ 1,000,000, there are 500,000 even numbers, and exceptions where n = 3+2x are 499,998 numbers. However we need to add back 2 as both 2 and 4, although being forms of 2x are actually winning states.

So the number of values of n for which the first player can force a win for 1 ≤ n ≤ 1,000,000 is 500,000 – 499,998 + 2 = 4.

More Answers:
Multiples with Small Digits
Primonacci
Reflexive Position

Error 403 The request cannot be completed because you have exceeded your quota. : quotaExceeded

Share:

Recent Posts

Mathematics in Cancer Treatment

How Mathematics is Transforming Cancer Treatment Mathematics plays an increasingly vital role in the fight against cancer mesothelioma. From optimizing drug delivery systems to personalizing

Read More »