A light can only be turned on if there is a light next to it turned on. In how many ways can you turn on all the lights? There are $n$ lights(numbered from $1$ to $n$), some of them are turned on. A turned off light can only be turned on if there is a light next to it turned on.
In how many ways can you turn on all the lights?
For example:
$$n=5$$
and the light number $3$ is on.
$$0 0 1 0 0$$
answer is 6.
6 ways
43*12
32*14
42*13
41*23
31*24
21*34
The * means the initial turned on light. The numbers indicate the order in which the  lights were turned on
I have tried recursively building the solution. But it is not time feasible.
A turned on light never goes off.
 A: Let there be m sequences of consecutive lights which are turned off, and $a_i$ be number of lights of each sequence,$i\in\{1,...,m\}$. 
If you watch only one sequence there is difference if the sequence is between two lightened lightballs or is at the end of row. If it is between then there is $2^{a_m-1}$ ways to choose order in which you will light them up, LRRLRR f.e. If it is on the end of row then there is only one way to turn them on going one by one.
Once you picked order of turning lights of each sequence you must decide order of the sequences you will turn a light from in each round. Number of it is $\frac{(\sum a_i)!}{\Pi (a_i!)}$
And total number is $\frac{(\sum a_i)!}{\Pi (a_i!)}\Pi (2^{a_j-1})$ where $j$ are indexes of the sequences that are in middle, so possibly without 1 or n.
In your example there are no sequences in the middle so you just have $\frac{(2+2)!}{ 2!2!}=6$
Here is an example which is more complicated: 0010001100001
So $a_1=2, a_2=3, a_3=4$ answer is $\frac{(2+3+4)!}{ 2!3!4!}2^{3-1}2^{4-1}$
A: *

*I don't know what is given as data, but if the positions of turned on lamps is given first you should extract all contiguous extinguished lightbulbs.


Example:
000111010100110000
S= {{1,2,3},{7},{9},{11,12},{15,16,17,18}}
Next get the cardinals: |S|={3,1,1,2,4} 
If you try to visualise the problem as a set of permutations, solution is just a multinomial distribution $\binom{n}{3,4,(1-1),(1-1),(2-1)}$
For a set of cardinals $|S|=\{x_0,x_1,x_2,x_3,x_4,...x_i\}$
Solution is $\binom{n}{x_0,\sum_j(x_1-j-1,j_1),\sum_j(x_2-j-2,j_2),...,x_i}$
$$=\sum_{j_1,j_2,...=0}\frac{n!}{x_0!(x_1-j_1-1)!j_1!(x_2-j_2-1)!j_2!...!x_i!}$$
Where $n$ is the number of extinct bulbs=$x_0+x_1+...x_n$.
Explanation:
For instance, a particular set of $x_0,x_1-j_1,j_1,x_2-j_2,j_2,...x_i$ and n extinct bulbls, permutations of these elements just notes the order of choosing either of these contiguous sub-lists, the act of choosing a sublist is visioned as clicking the edgemost switch of aligned ones that are all switched off, why $x_j-j-1$ ? because a set of complete $x_j$ encompasses one that is arranged with different list, so removing 1 from both opposite subsets as reserving a "nobody's land" of length=1 at the middle corrects the problem of duplicate choices.

Edit: After a bit of thinking i realised that a coincidence of choosing the no-cross line fixed between opposite subsets before $j$ or $x-j-1$ elements must be excluded, hence divided upon. 
$S=\sum_{j_1,j_2,...=0}\frac{n!}{x_0!(x_1-j_1-1)!j_1!(j_1-1)(x_1-j_1-2)(x_2-j_2-1)!j_2!(j_2-1)(x_2-j_2-2)...!x_i!}$=$$\sum_{j_1,j_2,...=0}\frac{n!}{x_0!(x_1-j_1-1)!j_1!(x_2-j_2-1)!j_2!...!x_i!*(j_1-1)(x_1-j_1-2)(j_2-1)(x_2-j_2-2)...}$$
