There are n ≥ 2 lamps L_{1}, L_{2}, ..., L_{n} in a row.
Each of them is either on or off.
Initially L_{1} is on and all of the others are off. Each second the state of each
lamp changes as follows:

if the lamp and its neighbors (L_{1} and L_{n} have one neighbor, any other lamp
has two neighbors) are in the same state, then it is switched off; otherwise,
it is switched on.

Prove or disprove that all of the lamps will eventually be switched off
if and only if n is a power of two.

Note: This is a problem that I modified from one proposed but not used at
the 47^{th} IMO in Slovenia 2006.

First, let us examine n=2 (2^{1}): 1|0 <- initial state [phase 0] -+- 1|1 <- a phase n/2, the pattern becomes -+- a mirror image ; the pattern on the 0|0 right is the same as the initial state

Then, let us examine n=4 (2^{2}): 10|00 <- initial state 11|00 --+-- 01|10 <- at phase n/2, the pattern becomes 11|11 a mirror image; the pattern on the --+-- right is the same as the initial state 00|00

Then, let us examine n=8 (2^{3}): 1000|0000 <- initial state 1100|0000 0110|0000 1111|0000 ----+---- 0001|1000 <- at phase n/2, the pattern becomes 0011|1100 a mirror image; the pattern on the 0110|0110 right is the same as the initial 1111|1111 state ----+---- 0000|0000

As can be observed, the top left 'sector' of the next power of 2 is identical to the top four sectors of the power of 2 that precedes it. Each, at phase n/2, becomes mirror images of the 'sector' vertically adjacent; and then at phase n all lamps are off. Thus, for all powers of 2, the lamps will all be in an off state at phase n.