This is again another famous olympiad problem. (IMO - 1993)
Solution to (A)
First, the sequence cannot terminate: it can only terminate if it reaches configuration with all lamps off, which is not possible, since if after some step
the configuration is all lamps off, that must have been the configuration before step
, so backtracking, the initial configuration must have been all off, which isn't true. Consider the infinite set of configurations after
steps for some integer
. Since there are only finitely many different configurations, some two must coincide. Choose the first such pair, after say
and
steps. So after
steps, the configurations just cycle. Now consider backtracking from step
to step
(by backtracking, replace the relavent pair of switches as follows:
(0,0) and (0,1) are unchanged, (1,0) goes to (1,1) and (1,1) goes to (1,0) ) :
consider the sequence of steps taking step
to step
. Now applying the same sequence of steps to step
, we can see by backtracking, after exactly
steps we will reach a configuration with all lamps on.