Solution

A Ladder with Steps 1, 3 and 4

Show the problem again

A single pile holds n stones. Two players alternate; on each turn a player removes exactly 1, 3 or 4 stones (never more than remain), and the player who takes the last stone wins. For how many values of n with 1 ≤ n ≤ 1000 does the second player win with optimal play? Give an integer.

Worked solution

The answer is 285. Claim: the player to move loses exactly when n ≡ 0 or 2 (mod 7). Check closure. From n ≡ 0, the moves 1, 3, 4 reach residues 6, 4, 3. From n ≡ 2, they reach residues 1, 6, 5. None of these is 0 or 2, so every move from a claimed-losing position lands in a winning one. Conversely, from residue 1 take 1 (to 0), from 3 take 3, from 4 take 4, from 5 take 3 (to 2), from 6 take 4 (to 2): every other residue can move into the losing set. Starting from the terminal position 0 (and 1, 2 verified directly), induction proves the claim. Within 1..1000 there are 142 multiples of 7 and 143 numbers congruent to 2 mod 7 (2, 9, ..., 996), so 142 + 143 = 285 losing starting sizes.

Source: Classic subtraction game; no traceable original source. Statement written for AxiomIQ.