Qm

Take one, three or four

A pile holds 20 stones. On a turn a player removes 1, 3 or 4 stones (never 2). The player who takes the last stone wins.

Who wins from 20 with best play, and what is the winning first move? Find the pattern of losing positions and explain why it repeats.

Show a hint

Work upwards from 0, marking each pile size as losing or winning. Look for a repeating block.

Your answer

Solving needs a free account

Answers, streaks and solutions unlock when you are signed in. Reading the question and the hint stays free.

Discussion

Sign in to join the discussion · reading is open to everyone

💡 Discussion rules

  1. No full solutions here. Hints and approaches only.
  2. Complexity, edge cases and intuition are the point.
  3. Interview experiences are welcome. Respect your NDAs.

Loading discussion…

Learn the concepts

The theory behind this question.

Related questions

Nim where the last stone losesTake one, two or four stonesTwenty coins in a circleGuess each other's coinPlacing knights so that none attack
All questions →