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
💡 Discussion rules
- No full solutions here. Hints and approaches only.
- Complexity, edge cases and intuition are the point.
- Interview experiences are welcome. Respect your NDAs.
Loading discussion…
Learn the concepts
The theory behind this question.