Qm
BrainteasersJane Street

The bulbs in a ring that always come back on

Bulbs numbered 1 to n are arranged in a ring, all initially on. At step t (for t = 1, 2, 3, ...) you look at bulb number t (counting round the ring, so bulb n is followed by bulb 1). If bulb t is on, you toggle bulb t + 1 (turn it off if on, on if off). If bulb t is off, you do nothing. Then you move on to step t + 1.

Prove that, whatever n is, at some later step all the bulbs are on again.

Show a hint

The state of the ring after each step is completely determined by the state before it, and there are only finitely many states. Show that each step can be undone, so the process cannot fall into a loop that misses the starting state.

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

Chameleons changing colorsThe 100 lockers problemThe 24-stone game where taking the last stone losesTwo opposite points with the same temperatureAnts falling off a rod
All questions →