$n$ lamps around a circle, find all $n$ such that the lamps can all be turned off after some moves.

combinatorics

Suppose there are $n \ge 3$ lamps around a circle, some switched on, the rest off. Let each move consist of toggling $3$ consecutive lamps. Find all $n$ such that it is possible to switch all lamps off after using a number of moves.

I've conjectured that all $n \equiv 0 \pmod{3}$ is impossible, while all other $n$ is possible through brute force. I'm trying to prove that for all $n$ not divisible by $3$ it is possible to execute a sequence of moves such that after the entire sequence, exactly one lamp has changed state, but I'm having some trouble. Any suggestions would be helpful.

Best Answer

You are correct, you can always turn off all the lamps if and only if $n\not\equiv 0\pmod 3$. Since this is a fun puzzle, I would prefer to give hints.

  • If $n\equiv 0\pmod 3$, imagine dividing the lamps into three groups, red, green, and blue, by the repeating pattern $R, G, B, R, G, B,\dots$ Think about how the operation interacts with the lamps in each grouping, and find an invariant quantity.

  • If $n\not\equiv 0\pmod 3$, note that by toggling the block $(i,i+1,i+2)$, and then $(i+1,i+2,i+3)$, then net effect is that only $i$ and $i+3$ are toggled. Using this, you can also toggle $(i,i+6)$ alone, and $(i,i+9)$ alone, and in general $(i,i+3k)$ alone for any $k$, where the indices wrap around mod $n$. Since $3$ and $n$ are coprime, this allows you to toggle $(i,i+j)$ for any $j$ (how?). With this power, you should be able to figure out how how to turn off all the lights.

Related Question