A row of lamps is labelled from left to right with the numbers to , where is an odd positive integer. Each lamp has a switch which, if pressed, turns it from OFF to ON or from ON to OFF; however the switches may only be pressed according to the following rules:
(a) Switch 1 may be pressed at any time;
(b) Switch may be pressed if and only if lamp is ON and all lamps (if any) are OFF.
Initially all lamps are ON. Prove that the minimum number of times the switches must be pressed to turn all the lamps OFF is
Solution
For any , let denote the minimum number of times the switches must be pressed to turn all the lamps OFF. It is easy to check that and .
Consider the problem of turning lamps from all ON to all OFF, for some . First, lamp must be turned OFF at some stage. For this to happen, lamps must all be OFF. This requires a minimum of switches to be pressed. Then one more switch is required to be pressed in order to turn lamp OFF. Next consider lamp . To turn lamp OFF, lamp must be turned ON. But to turn lamp ON, lamp must be turned ON, and so on (proof completed by induction). Therefore before lamp may be turned OFF, at least as many switches must be pressed as are required to turn all lamps ON - this requires at the minimum a further switches to be pressed (note that the number of switches required to turn all lamps from OFF to ON is the same as the number required to turn all lamps from ON to OFF). Finally, to turn lamps OFF requires a minimum of switches to be pressed. Summarising,
for . It is easy to see that the above reasoning defines recursively an algorithm which performs the required switchings while satisfying (1) with equality. Therefore
Next we prove by induction that for every ,
This is evident for . Assuming it is true for , we have
and so for we have by (2)
and
We conclude that for any odd positive integer , we have , so and therefore