Stone Picking Game with Optimal Position Choice

Game Theory · Medium · Free problem

Alice and Bob play a stone-picking game. There is a pile of $n$ stones. On each turn, a player must take between

$ and $r$ stones (inclusive) from the pile. The player who takes the last stone loses. They alternate turns, and Alice gets to choose whether she goes first or second.

You are given that $n \equiv 1 \pmod{r+1}$. Assume both players play optimally.

  1. Should Alice choose to go first or second?
  2. Describe the winning strategy.
  3. Compute the total number of turns (moves by both players combined, including the final losing move) when $n = 101$ and $r = 4$.

Hints

  1. Think about what happens if the total stones removed by both players in consecutive turns always sums to a fixed constant.
  2. Since $n \equiv 1 \pmod{r+1}$, you can write $n = k(r+1) + 1$. The second player can always "complement" the first player's move so that each pair of moves removes exactly $r+1$ stones.
  3. After $k$ paired rounds, exactly
    $ stone remains. Count: $k$ rounds of
$ moves each, plus
$ forced final move, gives
k + 1$ total turns.

Worked Solution

How to Think About It: This is a classic misere Nim variant. The key structural feature is the modular condition $n \equiv 1 \pmod{r+1}$. Before doing any formal work, think about it this way: if you can always force the pile to shrink by exactly $r+1$ stones every two moves, then whoever controls the "response" move controls the game. Since $n - 1$ is divisible by $r+1$, you can pair off moves until exactly 1 stone remains -- and then whoever moves next is stuck taking it and losing. That means the second player has the power here, so Alice should go second.

Quick Estimate: With $n = 101$ and $r = 4$, we have $r + 1 = 5$. The pile has

01 = 20 \times 5 + 1$ stones. So there will be 20 "rounds" of paired moves, each removing 5 stones, reducing the pile from 101 to 1. Then one final forced move. That is
0 \times 2 + 1 = 41$ turns. Let us verify this makes sense: 40 moves remove $40 / 2 \times 5 = 100$ stones, leaving 1 stone for Bob's forced losing move. Checks out.

Approach: We use the standard modular strategy for misere Nim with a single pile.

Formal Solution:

Since $n \equiv 1 \pmod{r+1}$, write $n = k(r+1) + 1$ where $k = \frac{n-1}{r+1}$.

The total number of turns is:

$\text{Total turns} = 2k + 1 = 2 \cdot \frac{n-1}{r+1} + 1$

Note: the k$ counts the paired moves (one per player per round), and the $+1$ is Bob's forced final move.

Plugging in $n = 101$ and $r = 4$:

$k = \frac{101 - 1}{4 + 1} = \frac{100}{5} = 20$

$\text{Total turns} = 2(20) + 1 = 41$

Answer: Alice should go second. Her strategy is to always take $r + 1 - j$ stones after Bob takes $j$, ensuring each round removes exactly $r + 1 = 5$ stones. The game lasts \cdot \frac{n-1}{r+1} + 1 = \mathbf{41}$ turns.

Intuition

This problem illustrates the modular invariant strategy that underlies most combinatorial Nim-type games. The core principle: if you can force the game state to hit a losing position for your opponent at every step, you win -- and in single-pile misere Nim, the losing positions are exactly those where the pile size is congruent to

\pmod{r+1}$. The second player maintains this invariant by "complementing" each of the first player's moves.

This pattern shows up broadly in combinatorial game theory and has direct analogs in adversarial decision-making. In trading, the same structural thinking applies whenever you face an adversary who moves first and you get to respond: your advantage comes from having a well-defined response function that keeps you in a favorable state regardless of what the other side does. The common mistake here is overthinking the strategy -- people try to reason about specific move sequences instead of recognizing the modular structure that makes the second player's response completely deterministic.

Open the full interactive solver →