SlideShare a Scribd company logo
1 of 34
Download to read offline
Lights Out Classic
Variations of the Lights Out Puzzle
The Lights Out Puzzle and Its Variations
Pengfei Li
School of Computing
Clemson University
November 30, 2011
Pengfei Li The Lights Out Puzzle and Its Variations
Lights Out Classic
Variations of the Lights Out Puzzle
Outline
1 Lights Out Classic
Introduction
Solving the Lights Out Classic
Initial Observations
Linear Algebraic Analysis
Solving the Puzzle by Hand
2 Variations of the Lights Out Puzzle
Generalizations of the Lights Out
Variations of the Game Board
Lights Out 2000
Restrictions on the Lights Out Classic
Lit-only Lights Out
The Toggle Game
Pengfei Li The Lights Out Puzzle and Its Variations
Lights Out Classic
Variations of the Lights Out Puzzle
Introduction
Solving the Lights Out Classic
Introduction - The Goal and Rules
A lights out game on iPhonea
a
Image Source: http://itunes.apple.com
What is the “Lights Out Puzzle”?
An electronic game firstly released in 1995
5 × 5 array of 25 lighted buttons
Each light has 2 states (ON or OFF)
The game starts with an initial pattern of lights.
Rules
When one button is toggled, the lights on it and its neighbors
change states. (ON → OFF, or OFF → ON)
Buttons on the edges/corners have only 3/2 neighbors.
Goal
Turn all lights OFF.
Use as few steps of toggling as possible.
Pengfei Li The Lights Out Puzzle and Its Variations
Lights Out Classic
Variations of the Lights Out Puzzle
Introduction
Solving the Lights Out Classic
Solving the Lights Out Classic (An Example)
Solving a lights out puzzle of the initial pattern with 4 steps.
The button with red frame is the one to be toggled in each step.
Pattern 1
(initial)
Pattern 2
(after step 1)
Pattern 3
(after step 2)
Pattern 4
(after step 3)
All-OFF Pattern
(Done!)
Pengfei Li The Lights Out Puzzle and Its Variations
Lights Out Classic
Variations of the Lights Out Puzzle
Introduction
Solving the Lights Out Classic
Questions to Answer...
We might be interested in these questions:
The 25 lights contribute to 225 different patterns in total.
1 Given a random pattern, is it possible to turn all the lights off?
2 If not, how many patterns are solvable?
3 How to solve a pattern if it is solvable?
4 What is the optimal solution? (The one with minimum steps of toggling)
Pengfei Li The Lights Out Puzzle and Its Variations
Lights Out Classic
Variations of the Lights Out Puzzle
Introduction
Solving the Lights Out Classic
Initial Observations
What contributes to the light states? (An experiment)
2
33
0 1 0
0
1
1
111
0
1
1
2
5
0 0
00
3
4
2
3
(Odd) (Even)
1 Initial state
2 Parity of toggling time of each and its neighbors
Basic Conclusion 1.1
The set of lights affected is irrelevant to the sequence in which the buttons are toggled.
Basic Conclusion 1.2
Toggling a button twice is equivalent to not toggling it at all. (Once is enough!)
Pengfei Li The Lights Out Puzzle and Its Variations
Lights Out Classic
Variations of the Lights Out Puzzle
Introduction
Solving the Lights Out Classic
Further Observation
A further conclusion:
Solve Restore
Basic Conclusion 1.3
If one pattern can be solved by toggling a set of buttons, then starting with the all-OFF
pattern and toggling the same set of buttons will restore the original one.
Let’s begin the linear algebraic analysis...
Pengfei Li The Lights Out Puzzle and Its Variations
Lights Out Classic
Variations of the Lights Out Puzzle
Introduction
Solving the Lights Out Classic
The Grid Graph & Neighborhood Matrix
Consider the 5 × 5 array as a grid graph...
Definition 1.1
The neighborhood matrix of a graph is the
adjacency matrix plus an identity matrix of
the same size: N = A + I.
N =















1 1 0 0 0 1 0 . . . 0
1 1 1 0 0 0 1 . . . 0
0 1 1 1 0 0 0 . . . 0
0 0 1 1 1 0 0 . . . 0
0 0 0 1 1 0 0 . . . 0
1 0 0 0 0 1 1 . . . 0
0 1 0 0 0 1 1 . . . 0
...
...
...
...
...
...
...
...
...
0 0 0 0 0 0 0 . . . 1















All 1s on its diagonal instead of all 0s
Each row/column indicates the lights affected
Pengfei Li The Lights Out Puzzle and Its Variations
Lights Out Classic
Variations of the Lights Out Puzzle
Introduction
Solving the Lights Out Classic
Indicator Vectors
Definition 1.2
The toggling indicator vector and pattern indicator vector, denoted x and b respectively,
are 25 × 1 vectors over Z2 (Z2 = {0, 1}) indicating the sets of buttons to be toggled and the
patterns of the 5 × 5 array in row-by-row sequence.






0 0 0 0 0
0 0 0 0 0
1 0 0 0 0
0 1 0 1 0
0 0 0 0 1












0 0 0 0 0
1 0 0 0 0
1 0 0 1 0
0 1 0 1 0
0 1 0 0 1






x = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1)T
b = (0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1)T
Pengfei Li The Lights Out Puzzle and Its Variations
Lights Out Classic
Variations of the Lights Out Puzzle
Introduction
Solving the Lights Out Classic
What is the product of N and x over Z2?
We use and to represent XOR and matrix multiplication over Z2.
Suppose x = (1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)T.
N x =















1 1 0 0 0 1 0 . . . 0
1 1 1 0 0 0 1 . . . 0
0 1 1 1 0 0 0 . . . 0
0 0 1 1 1 0 0 . . . 0
0 0 0 1 1 0 0 . . . 0
1 0 0 0 0 1 1 . . . 0
0 1 0 0 0 1 1 . . . 0
...
...
...
...
...
...
...
...
...
0 0 0 0 0 0 0 . . . 1






























1
0
1
0
1
0
0
...
0















=















1
1
0
0
0
1
0
...
0






























0
1
1
1
0
0
0
...
0






























0
0
0
1
1
0
0
...
0















=















1
0
1
0
1
1
0
...
0















The product is the XOR of some columns of N selected by x.
It indicates the lights whose states changed (the pattern restored by the toggling of x).
Pengfei Li The Lights Out Puzzle and Its Variations
Lights Out Classic
Variations of the Lights Out Puzzle
Introduction
Solving the Lights Out Classic
Basic Conclusion of Solvability
Together with previous conclusions, we have the following:
Theorem 1.1
A pattern of the lights out puzzle is solvable iff there exists a vector x such that N x = b
where b is the indicator vector of the pattern.
Now we have reduced the problem to the solvability of a system of linear equations.
Although all operations are over Z2, theorems in linear algebra still follow.
(1) Given a random pattern, is it possible to turn all the lights off?
No. Since det (N) = 0, the system of linear equations does not always have a solution.
(2), (3) and (4) will be answered after a few more analysis on N...
Pengfei Li The Lights Out Puzzle and Its Variations
Lights Out Classic
Variations of the Lights Out Puzzle
Introduction
Solving the Lights Out Classic
Solving the System of Equations N x = b
We perform elementary row operations on N until it reaches reduced row echelon form E.
N ∼ E =













1 0 0 0 . . . 0 0 1
0 1 0 0 . . . 0 1 0
0 0 1 0 . . . 0 1 1
0 0 0 1 . . . 0 1 0
...
...
...
...
...
...
...
...
0 0 0 0 . . . 1 1 1
0 0 0 0 . . . 0 0 0
0 0 0 0 . . . 0 0 0













=
I23×23 M23×2
O2×23 O2×2
(rank (N) = 23)
N x = b has a solution ⇔ b belongs to Col N ⇔ b belongs to (Nul NT)⊥
⇔ b belongs to (Nul N)⊥ ⇔ b belongs to (Nul E)⊥ ⇔ b ⊥ an orthogonal basis of Nul E
Pengfei Li The Lights Out Puzzle and Its Variations
Lights Out Classic
Variations of the Lights Out Puzzle
Introduction
Solving the Lights Out Classic
Solvability Conclusion by Linear Algebra
An orthogonal basis for Nul E from last 2 columns of E =
I23×23 M23×2
O2×23 O2×2
Replacing the zero matrix O2×2 with an identity matrix I2×2, we get an orthogonal basis:
n1 = (0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0)T
n2 = (1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1)T
n1 and n2 can be used as test vectors.
Putting all these together, we have:
Theorem 1.2
A pattern of the lights out puzzle is solvable iff b ⊥ n1 and b ⊥ n2 where b is the indicator
vector of the pattern.
Pengfei Li The Lights Out Puzzle and Its Variations
Lights Out Classic
Variations of the Lights Out Puzzle
Introduction
Solving the Lights Out Classic
Test the Solvability (An Example)
We use to represent the dot product over Z2. (a ⊥ b ⇔ a b = 0)
c n1 = 1
c n2 = 0
c ⊥ n1
m n1 = 0
m n2 = 0
m ⊥ n1 and m ⊥ n2
The pattern “C” is not solvable, but the pattern “M” is!
Pengfei Li The Lights Out Puzzle and Its Variations
Lights Out Classic
Variations of the Lights Out Puzzle
Introduction
Solving the Lights Out Classic
How Many Patterns Are Solvable?
N x = b has a solution ⇔ rank (N|b) = rank (N) = 23 (How to satisfy?)
(N|b) =











1 1 0 . . . 0 0 0 b1
1 1 1 . . . 0 0 0 b2
0 1 1 . . . 0 0 0 b3
...
...
...
...
...
...
...
...
0 0 0 . . . 1 1 0 b23
0 0 0 . . . 1 1 1 b24
0 0 0 . . . 0 1 1 b25











∼











1 0 0 . . . 0 0 1 e1
0 1 0 . . . 0 1 0 e2
0 0 1 . . . 0 1 1 e3
...
...
...
...
...
...
...
...
0 0 0 . . . 1 1 1 e23
0 0 0 . . . 0 0 0 0
0 0 0 . . . 0 0 0 0











If we want rank (N|b) to be 23, and we have assigned b1, b2, . . . , b23 with values of 0s and
1s, only one pair of (b24, b25) in {(0, 0), (0, 1), (1, 0), (1, 1)} satisfies!
23 of the lights are free, 2 lights are constrained.
i.e. Only 1/4 of all patterns are solvable. There are 223 solvable patterns in total.
Pengfei Li The Lights Out Puzzle and Its Variations
Lights Out Classic
Variations of the Lights Out Puzzle
Introduction
Solving the Lights Out Classic
How to Solve for x in N x = b ?
1 Gauss-Jordan elimination on (N|b)
2 N x = b ⇔ x = N−1 b if N is invertible (rank (N) = 23)
A trick: Compute the pseudo-inverse of N:
Gauss-Jordan elimination on (N|I)25×50
N25×25 I25×25 ∼ E25×25
ˆN25×25
Then ˆN is the pseudo-inverse of N.
Algorithm 1.1
For any solvable pattern b, x = ˆN b gives one solution of the pattern.
How to find the optimal solution? This is an O(n2) algorithm. Can we have a better one?
Pengfei Li The Lights Out Puzzle and Its Variations
Lights Out Classic
Variations of the Lights Out Puzzle
Introduction
Solving the Lights Out Classic
Stable Togglings
Since n1, n2 ∈ Nul N and Nul N = {x ∈ {0, 1}25 | N x = 0},
n1 and n2 indicate the “stable” togglings!
0 (trivial) n1 n2 n1 n2
These are all the linear combinations of n1 and n2 over Z2. i.e. Only 4 stable togglings exist.
For a solvable pattern, there are 4 solutions. The optimal one is one of them.
From the all-OFF pattern, every 4 different togglings generate the same pattern.
Pengfei Li The Lights Out Puzzle and Its Variations
Lights Out Classic
Variations of the Lights Out Puzzle
Introduction
Solving the Lights Out Classic
How Many Steps Needed at Most?
cba
a d ad
b b d b
d a d a
c b a b c
a
a
bc
b
Partition
n1
n2
n1 n2
Suppose that the optimal solution x has X
buttons to be toggled. X = A + B + C + D
x n1 has (8 − A) + (8 − B) + C + D buttons.



X ≤ (8 − A) + (8 − B) + C + D
X ≤ (8 − A) + B + (4 − C) + D
X ≤ A + (8 − B) + (4 − C) + D
D ≤ 5
⇒ max (A + B + C + D) = 15
Theorem 1.3
Every solvable pattern of the lights out puzzle can
be solved within 15 steps.
Pengfei Li The Lights Out Puzzle and Its Variations
Lights Out Classic
Variations of the Lights Out Puzzle
Introduction
Solving the Lights Out Classic
What Have We Done?
We have answered all the questions.
We know the solvability, the number of solutions and the way to find the optimal one.
But, how to solve the puzzle by hand?
Also, we prefer an algorithm of O(n) than of O(n2).
Pengfei Li The Lights Out Puzzle and Its Variations
Lights Out Classic
Variations of the Lights Out Puzzle
Introduction
Solving the Lights Out Classic
Testing the Solvability by Hand
Continue considering the 3 non-trivial stable togglings...
When toggling a button, numbers of the “blue” buttons affected: 0, 2, 4 (Even)
i.e. Pattern is solvable ⇒ number of lit buttons overlapped with the “blue” buttons is even.
The other direction of this proposition can also be proved.
Actually, only 2 of the 3 non-trivial stable togglings need to be tested.
Pengfei Li The Lights Out Puzzle and Its Variations
Lights Out Classic
Variations of the Lights Out Puzzle
Introduction
Solving the Lights Out Classic
Testing the Solvability by Hand (An Example)
The Pattern “C”
Test Patterns Overlapped
|{c} ∩ {n1}| = 2 (Even)
|{c} ∩ {n1 n2}| = 5 (Odd)
Result: Not solvable!
Pengfei Li The Lights Out Puzzle and Its Variations
Lights Out Classic
Variations of the Lights Out Puzzle
Introduction
Solving the Lights Out Classic
Chasing the Lights Down
What is the universal way of solving all 223 solvable patterns?
A trick: Chasing the lights Down:
All lit buttons can only be in the last row.
In the last row, 3 lights are free, 2 lights are constrained. (if solvable)
i.e. We have merged all the 223 cases into 23 = 8 cases.
Pengfei Li The Lights Out Puzzle and Its Variations
Lights Out Classic
Variations of the Lights Out Puzzle
Introduction
Solving the Lights Out Classic
The 8 Cases after Chasing
These are the 8 possible last-row patterns after chasing:
The other 25 − 8 = 24 last-row patterns are not solvable!
After chasing, we can decide which case the pattern is in.
In the first case: We have done!
In the other 7 cases: Minutely adjust the pattern to shift it to the first case.
Pengfei Li The Lights Out Puzzle and Its Variations
Lights Out Classic
Variations of the Lights Out Puzzle
Introduction
Solving the Lights Out Classic
The Algorithm
Algorithm 1.2
Number the rows 1-5, the columns A-E.
1 Chase the lights down to make all lit lights in row 5.
2 If the light at A5 is on then toggle D1 and E1.
3 If the light at B5 is on then toggle B1 and E1.
4 If the light at C5 is on then toggle D1.
5 Chase the lights down again until all lights off.
6 Delete the redundant buttonsa, and then XOR the
solution with 3 non-trivial stable togglings to get the
optimal one.
a
The buttons been toggled twice
E1D1B1
C5B5A5
This algorithm is in O(n).
Pengfei Li The Lights Out Puzzle and Its Variations
Lights Out Classic
Variations of the Lights Out Puzzle
Outline
1 Lights Out Classic
Introduction
Solving the Lights Out Classic
Initial Observations
Linear Algebraic Analysis
Solving the Puzzle by Hand
2 Variations of the Lights Out Puzzle
Generalizations of the Lights Out
Variations of the Game Board
Lights Out 2000
Restrictions on the Lights Out Classic
Lit-only Lights Out
The Toggle Game
Pengfei Li The Lights Out Puzzle and Its Variations
Lights Out Classic
Variations of the Lights Out Puzzle
Generalizations of the Lights Out
Restrictions on the Lights Out Classic
Variations of the Game Board (Examples)
Different game board shapes
Last-Out Lights Out Cube
Image Source: http://www.powerstrike.net
Different neighborhood definitions
4 neighbors
8 neighbors
“X” neighbors
“O” neighbors
None of these variations makes the game harder!
Just change another neighborhood matrix N and perform the similar analysis.
Pengfei Li The Lights Out Puzzle and Its Variations
Lights Out Classic
Variations of the Lights Out Puzzle
Generalizations of the Lights Out
Restrictions on the Lights Out Classic
Lights Out 2000
T( ) =
T( ) =
T( ) =
In lights out 2000, each light has 3 states.
It is a modulo 3 game instead of modulo 2.
Performing the similar analysis (changing to mod 3), we can get:
There are 22 free lights, 3 constrained lights.
322 = 31, 381, 059, 609 solvable patterns exist.
33 = 27 different stable togglings exist.
Every solvable pattern can be solved within 24 steps.
An O(n2) algorithm by solving a system of linear equations
An O(n) algorithm by “chasing the lights down”
Pengfei Li The Lights Out Puzzle and Its Variations
Lights Out Classic
Variations of the Lights Out Puzzle
Generalizations of the Lights Out
Restrictions on the Lights Out Classic
Conclusions of the Generalized Lights Out
For any generalizations of the lights out puzzle, if
Number of buttons: m
Number of states of each button: s
Nullitya of the neighborhood matrix: n
Then
Number of free lights: m − n
Number of constrained lights: n
Number of all patterns: sm
Number of solvable patterns: sm−n
Number of different stable togglings: sn
For some game board shapes, we can consider rotations and mirrors to make it simpler.
a
Nullity is the dimension of the null space
Pengfei Li The Lights Out Puzzle and Its Variations
Lights Out Classic
Variations of the Lights Out Puzzle
Generalizations of the Lights Out
Restrictions on the Lights Out Classic
Lit-only Lights Out
This game is a little tricky. It is the lights out classic with the restriction:
Restriction 2.1
Only lit buttons are allowed to be toggled:
. . .
If you toggle an unlit buttons, the pattern stays unchanged.
Theorem 2.1
A pattern in lit-only lights out can be solved iff it can be solved in lights out classic.
Key points:
1 The toggling sequence is important!
2 We might need to toggle some of the buttons more than once.
3 We might need more steps than solving the same pattern in lights out classic.
Pengfei Li The Lights Out Puzzle and Its Variations
Lights Out Classic
Variations of the Lights Out Puzzle
Generalizations of the Lights Out
Restrictions on the Lights Out Classic
The Algorithm for One Solution
Algorithm 2.1
1 Perform the classic algorithm until you’re not able to take more steps.
2 Find a path from one nearest lit button (source button) if existsa to
the button to be toggled (destination button).
3 Toggle the following buttons:
1 The source button
2 Buttons on the path (auxiliary buttons) in the path sequence
3 The destination button
4 The auxiliary buttons in some sequenceb
5 The source button
4 Repeat 1-3 until all lights off.
a
If no lit button exists, we have done!
b
You are always able do that. Just keep toggling a lit one then a sequence is found.
Pengfei Li The Lights Out Puzzle and Its Variations
Lights Out Classic
Variations of the Lights Out Puzzle
Generalizations of the Lights Out
Restrictions on the Lights Out Classic
The Algorithm for the Optimal Solution
...
...
...
...
...
...
...
...
The patterns graph
Build a directed patterns graph with 223 nodes.
Each node represents a solvable pattern.
Each edge represents that one pattern is reachable from
another by one step of toggling.
Only one edge exists between a pair of nodes.
The out-degree of one node is the number of lit buttons.
The out-degree of the all-OFF pattern node is 0.
Algorithm 2.2
Perform Breadth First Search on the patterns graph from
current pattern until the node with 0 out-degree is reached.
This is an O(2n) algorithm!
Pengfei Li The Lights Out Puzzle and Its Variations
Lights Out Classic
Variations of the Lights Out Puzzle
Generalizations of the Lights Out
Restrictions on the Lights Out Classic
The Toggle Game
It’s a more difficult game with the following restriction:
Restriction 2.2
You have to alternatively toggle one lit button and one unlit button:
. . . or . . .
If you toggle a wrong button, the pattern stays unchanged.
Key points:
The last step is always toggling a lit pattern to turn all lights off.
The first sequence has an odd number of steps, the second has an even number.
Since all solutions have the same parity, you must decide carefully which button
(lit/unlit) for the first step, or you’ll never be able to solve it.
Pengfei Li The Lights Out Puzzle and Its Variations
Lights Out Classic
Variations of the Lights Out Puzzle
References
Marlow Anderson and Todd Feil.
Turing lights out with linear algebra.
Mathematics Magazine, 71(4):300–303, 1998.
Peter J. Slater Ashok T. Amin and Guo hui Zhang.
Parity dimension for graphs - a linear algebraic approach.
Linear and Multilinear Algebra, 50(4):327–342, 2002.
Alexander Giffen and Darren B. Parker.
On generalizing the “lights out” game and a generalization of parity domination, 2009.
Jaap Scherphuis.
Jaap’s puzzle page (lights out).
http://www.jaapsch.net/puzzles/lights.htm.
[Online; 2010-01-31].
Jaap Scherphuis.
Jaap’s puzzle page (the mathematics of lights out).
http://www.jaapsch.net/puzzles/lomath.htm.
[Online; 2009-09-20].
Pengfei Li The Lights Out Puzzle and Its Variations
Lights Out Classic
Variations of the Lights Out Puzzle
The End
That’s All
Thanks!
Pengfei Li The Lights Out Puzzle and Its Variations

More Related Content

What's hot

Limit & Continuity of Functions - Differential Calculus by Arun Umrao
Limit & Continuity of Functions - Differential Calculus by Arun UmraoLimit & Continuity of Functions - Differential Calculus by Arun Umrao
Limit & Continuity of Functions - Differential Calculus by Arun Umraossuserd6b1fd
 
application of complex numbers
application of complex numbersapplication of complex numbers
application of complex numbersKaustubh Garud
 
Convolution and FFT
Convolution and FFTConvolution and FFT
Convolution and FFTChenghao Jin
 
Principle of Integration - Basic Introduction - by Arun Umrao
Principle of Integration - Basic Introduction - by Arun UmraoPrinciple of Integration - Basic Introduction - by Arun Umrao
Principle of Integration - Basic Introduction - by Arun Umraossuserd6b1fd
 
Bounded variables new
Bounded variables newBounded variables new
Bounded variables newSamo Alwatan
 
Principle of Derivative Calculus - Differential Calculus - An Introduction by...
Principle of Derivative Calculus - Differential Calculus - An Introduction by...Principle of Derivative Calculus - Differential Calculus - An Introduction by...
Principle of Derivative Calculus - Differential Calculus - An Introduction by...ssuserd6b1fd
 
Principle of Function Analysis - by Arun Umrao
Principle of Function Analysis - by Arun UmraoPrinciple of Function Analysis - by Arun Umrao
Principle of Function Analysis - by Arun Umraossuserd6b1fd
 
The Computational Algorithm for Supported Solutions Set of Linear Diophantine...
The Computational Algorithm for Supported Solutions Set of Linear Diophantine...The Computational Algorithm for Supported Solutions Set of Linear Diophantine...
The Computational Algorithm for Supported Solutions Set of Linear Diophantine...IJMER
 
STT802project-writeup-Final (1)
STT802project-writeup-Final (1)STT802project-writeup-Final (1)
STT802project-writeup-Final (1)James P. Regan II
 

What's hot (16)

Limit & Continuity of Functions - Differential Calculus by Arun Umrao
Limit & Continuity of Functions - Differential Calculus by Arun UmraoLimit & Continuity of Functions - Differential Calculus by Arun Umrao
Limit & Continuity of Functions - Differential Calculus by Arun Umrao
 
Ch07 7
Ch07 7Ch07 7
Ch07 7
 
application of complex numbers
application of complex numbersapplication of complex numbers
application of complex numbers
 
Ch04 1
Ch04 1Ch04 1
Ch04 1
 
Convolution and FFT
Convolution and FFTConvolution and FFT
Convolution and FFT
 
Principle of Integration - Basic Introduction - by Arun Umrao
Principle of Integration - Basic Introduction - by Arun UmraoPrinciple of Integration - Basic Introduction - by Arun Umrao
Principle of Integration - Basic Introduction - by Arun Umrao
 
Bounded var
Bounded varBounded var
Bounded var
 
Bounded variables new
Bounded variables newBounded variables new
Bounded variables new
 
COMPLEX NUMBER
COMPLEX NUMBERCOMPLEX NUMBER
COMPLEX NUMBER
 
Principle of Derivative Calculus - Differential Calculus - An Introduction by...
Principle of Derivative Calculus - Differential Calculus - An Introduction by...Principle of Derivative Calculus - Differential Calculus - An Introduction by...
Principle of Derivative Calculus - Differential Calculus - An Introduction by...
 
Ch07 8
Ch07 8Ch07 8
Ch07 8
 
Principle of Function Analysis - by Arun Umrao
Principle of Function Analysis - by Arun UmraoPrinciple of Function Analysis - by Arun Umrao
Principle of Function Analysis - by Arun Umrao
 
Ch07 6
Ch07 6Ch07 6
Ch07 6
 
The Computational Algorithm for Supported Solutions Set of Linear Diophantine...
The Computational Algorithm for Supported Solutions Set of Linear Diophantine...The Computational Algorithm for Supported Solutions Set of Linear Diophantine...
The Computational Algorithm for Supported Solutions Set of Linear Diophantine...
 
Manual solucoes ex_extras
Manual solucoes ex_extrasManual solucoes ex_extras
Manual solucoes ex_extras
 
STT802project-writeup-Final (1)
STT802project-writeup-Final (1)STT802project-writeup-Final (1)
STT802project-writeup-Final (1)
 

Similar to The Lights Out Puzzle and Its Variations

International Journal of Engineering Research and Development (IJERD)
International Journal of Engineering Research and Development (IJERD)International Journal of Engineering Research and Development (IJERD)
International Journal of Engineering Research and Development (IJERD)IJERD Editor
 
Bc2641334137
Bc2641334137Bc2641334137
Bc2641334137IJMER
 
Recurrent problems: TOH, Pizza Cutting and Josephus Problems
Recurrent problems: TOH, Pizza Cutting and Josephus ProblemsRecurrent problems: TOH, Pizza Cutting and Josephus Problems
Recurrent problems: TOH, Pizza Cutting and Josephus ProblemsMenglinLiu1
 
Introduction to Neural Netwoks
Introduction to Neural Netwoks Introduction to Neural Netwoks
Introduction to Neural Netwoks Abdallah Bashir
 
Equations and tilings
Equations and tilingsEquations and tilings
Equations and tilingsnavajomath
 
1Boolean Alegebra 3booleanalgebraold-160325120651.pdf
1Boolean Alegebra 3booleanalgebraold-160325120651.pdf1Boolean Alegebra 3booleanalgebraold-160325120651.pdf
1Boolean Alegebra 3booleanalgebraold-160325120651.pdfsiliconvalley6203
 
Image Acquisition and Representation
Image Acquisition and RepresentationImage Acquisition and Representation
Image Acquisition and RepresentationAmnaakhaan
 
18 pc09 1.2_ digital logic gates _ boolean algebra_basic theorems
18 pc09 1.2_ digital logic gates _ boolean algebra_basic theorems18 pc09 1.2_ digital logic gates _ boolean algebra_basic theorems
18 pc09 1.2_ digital logic gates _ boolean algebra_basic theoremsarunachalamr16
 
3 2--_2_first-order_differential_equati
3  2--_2_first-order_differential_equati3  2--_2_first-order_differential_equati
3 2--_2_first-order_differential_equatiIsidroMateus
 

Similar to The Lights Out Puzzle and Its Variations (20)

Grid Zero
Grid ZeroGrid Zero
Grid Zero
 
Finite difference & interpolation
Finite difference & interpolationFinite difference & interpolation
Finite difference & interpolation
 
International Journal of Engineering Research and Development (IJERD)
International Journal of Engineering Research and Development (IJERD)International Journal of Engineering Research and Development (IJERD)
International Journal of Engineering Research and Development (IJERD)
 
Bitwise
BitwiseBitwise
Bitwise
 
Bc2641334137
Bc2641334137Bc2641334137
Bc2641334137
 
Boolean algebra1
Boolean algebra1Boolean algebra1
Boolean algebra1
 
Recurrent problems: TOH, Pizza Cutting and Josephus Problems
Recurrent problems: TOH, Pizza Cutting and Josephus ProblemsRecurrent problems: TOH, Pizza Cutting and Josephus Problems
Recurrent problems: TOH, Pizza Cutting and Josephus Problems
 
Introduction to Neural Netwoks
Introduction to Neural Netwoks Introduction to Neural Netwoks
Introduction to Neural Netwoks
 
Equations and tilings
Equations and tilingsEquations and tilings
Equations and tilings
 
1Boolean Alegebra 3booleanalgebraold-160325120651.pdf
1Boolean Alegebra 3booleanalgebraold-160325120651.pdf1Boolean Alegebra 3booleanalgebraold-160325120651.pdf
1Boolean Alegebra 3booleanalgebraold-160325120651.pdf
 
Boolean alebra
Boolean alebraBoolean alebra
Boolean alebra
 
Section8 control
Section8 controlSection8 control
Section8 control
 
Section8 stochastic
Section8 stochasticSection8 stochastic
Section8 stochastic
 
1. introduction to complex numbers
1. introduction to complex numbers1. introduction to complex numbers
1. introduction to complex numbers
 
Image Acquisition and Representation
Image Acquisition and RepresentationImage Acquisition and Representation
Image Acquisition and Representation
 
Neural Networks.pptx
Neural Networks.pptxNeural Networks.pptx
Neural Networks.pptx
 
18 pc09 1.2_ digital logic gates _ boolean algebra_basic theorems
18 pc09 1.2_ digital logic gates _ boolean algebra_basic theorems18 pc09 1.2_ digital logic gates _ boolean algebra_basic theorems
18 pc09 1.2_ digital logic gates _ boolean algebra_basic theorems
 
Chapter 2.pdf
Chapter 2.pdfChapter 2.pdf
Chapter 2.pdf
 
Ch03 2
Ch03 2Ch03 2
Ch03 2
 
3 2--_2_first-order_differential_equati
3  2--_2_first-order_differential_equati3  2--_2_first-order_differential_equati
3 2--_2_first-order_differential_equati
 

Recently uploaded

STERILITY TESTING OF PHARMACEUTICALS ppt by DR.C.P.PRINCE
STERILITY TESTING OF PHARMACEUTICALS ppt by DR.C.P.PRINCESTERILITY TESTING OF PHARMACEUTICALS ppt by DR.C.P.PRINCE
STERILITY TESTING OF PHARMACEUTICALS ppt by DR.C.P.PRINCEPRINCE C P
 
BIOETHICS IN RECOMBINANT DNA TECHNOLOGY.
BIOETHICS IN RECOMBINANT DNA TECHNOLOGY.BIOETHICS IN RECOMBINANT DNA TECHNOLOGY.
BIOETHICS IN RECOMBINANT DNA TECHNOLOGY.PraveenaKalaiselvan1
 
CALL ON ➥8923113531 🔝Call Girls Kesar Bagh Lucknow best Night Fun service 🪡
CALL ON ➥8923113531 🔝Call Girls Kesar Bagh Lucknow best Night Fun service  🪡CALL ON ➥8923113531 🔝Call Girls Kesar Bagh Lucknow best Night Fun service  🪡
CALL ON ➥8923113531 🔝Call Girls Kesar Bagh Lucknow best Night Fun service 🪡anilsa9823
 
Analytical Profile of Coleus Forskohlii | Forskolin .pptx
Analytical Profile of Coleus Forskohlii | Forskolin .pptxAnalytical Profile of Coleus Forskohlii | Forskolin .pptx
Analytical Profile of Coleus Forskohlii | Forskolin .pptxSwapnil Therkar
 
Luciferase in rDNA technology (biotechnology).pptx
Luciferase in rDNA technology (biotechnology).pptxLuciferase in rDNA technology (biotechnology).pptx
Luciferase in rDNA technology (biotechnology).pptxAleenaTreesaSaji
 
Physiochemical properties of nanomaterials and its nanotoxicity.pptx
Physiochemical properties of nanomaterials and its nanotoxicity.pptxPhysiochemical properties of nanomaterials and its nanotoxicity.pptx
Physiochemical properties of nanomaterials and its nanotoxicity.pptxAArockiyaNisha
 
Artificial Intelligence In Microbiology by Dr. Prince C P
Artificial Intelligence In Microbiology by Dr. Prince C PArtificial Intelligence In Microbiology by Dr. Prince C P
Artificial Intelligence In Microbiology by Dr. Prince C PPRINCE C P
 
Dashanga agada a formulation of Agada tantra dealt in 3 Rd year bams agada tanta
Dashanga agada a formulation of Agada tantra dealt in 3 Rd year bams agada tantaDashanga agada a formulation of Agada tantra dealt in 3 Rd year bams agada tanta
Dashanga agada a formulation of Agada tantra dealt in 3 Rd year bams agada tantaPraksha3
 
Hubble Asteroid Hunter III. Physical properties of newly found asteroids
Hubble Asteroid Hunter III. Physical properties of newly found asteroidsHubble Asteroid Hunter III. Physical properties of newly found asteroids
Hubble Asteroid Hunter III. Physical properties of newly found asteroidsSérgio Sacani
 
Behavioral Disorder: Schizophrenia & it's Case Study.pdf
Behavioral Disorder: Schizophrenia & it's Case Study.pdfBehavioral Disorder: Schizophrenia & it's Case Study.pdf
Behavioral Disorder: Schizophrenia & it's Case Study.pdfSELF-EXPLANATORY
 
PossibleEoarcheanRecordsoftheGeomagneticFieldPreservedintheIsuaSupracrustalBe...
PossibleEoarcheanRecordsoftheGeomagneticFieldPreservedintheIsuaSupracrustalBe...PossibleEoarcheanRecordsoftheGeomagneticFieldPreservedintheIsuaSupracrustalBe...
PossibleEoarcheanRecordsoftheGeomagneticFieldPreservedintheIsuaSupracrustalBe...Sérgio Sacani
 
Grafana in space: Monitoring Japan's SLIM moon lander in real time
Grafana in space: Monitoring Japan's SLIM moon lander  in real timeGrafana in space: Monitoring Japan's SLIM moon lander  in real time
Grafana in space: Monitoring Japan's SLIM moon lander in real timeSatoshi NAKAHIRA
 
Boyles law module in the grade 10 science
Boyles law module in the grade 10 scienceBoyles law module in the grade 10 science
Boyles law module in the grade 10 sciencefloriejanemacaya1
 
Natural Polymer Based Nanomaterials
Natural Polymer Based NanomaterialsNatural Polymer Based Nanomaterials
Natural Polymer Based NanomaterialsAArockiyaNisha
 
Is RISC-V ready for HPC workload? Maybe?
Is RISC-V ready for HPC workload? Maybe?Is RISC-V ready for HPC workload? Maybe?
Is RISC-V ready for HPC workload? Maybe?Patrick Diehl
 
Isotopic evidence of long-lived volcanism on Io
Isotopic evidence of long-lived volcanism on IoIsotopic evidence of long-lived volcanism on Io
Isotopic evidence of long-lived volcanism on IoSérgio Sacani
 
Scheme-of-Work-Science-Stage-4 cambridge science.docx
Scheme-of-Work-Science-Stage-4 cambridge science.docxScheme-of-Work-Science-Stage-4 cambridge science.docx
Scheme-of-Work-Science-Stage-4 cambridge science.docxyaramohamed343013
 
Recombination DNA Technology (Nucleic Acid Hybridization )
Recombination DNA Technology (Nucleic Acid Hybridization )Recombination DNA Technology (Nucleic Acid Hybridization )
Recombination DNA Technology (Nucleic Acid Hybridization )aarthirajkumar25
 
All-domain Anomaly Resolution Office U.S. Department of Defense (U) Case: “Eg...
All-domain Anomaly Resolution Office U.S. Department of Defense (U) Case: “Eg...All-domain Anomaly Resolution Office U.S. Department of Defense (U) Case: “Eg...
All-domain Anomaly Resolution Office U.S. Department of Defense (U) Case: “Eg...Sérgio Sacani
 

Recently uploaded (20)

STERILITY TESTING OF PHARMACEUTICALS ppt by DR.C.P.PRINCE
STERILITY TESTING OF PHARMACEUTICALS ppt by DR.C.P.PRINCESTERILITY TESTING OF PHARMACEUTICALS ppt by DR.C.P.PRINCE
STERILITY TESTING OF PHARMACEUTICALS ppt by DR.C.P.PRINCE
 
BIOETHICS IN RECOMBINANT DNA TECHNOLOGY.
BIOETHICS IN RECOMBINANT DNA TECHNOLOGY.BIOETHICS IN RECOMBINANT DNA TECHNOLOGY.
BIOETHICS IN RECOMBINANT DNA TECHNOLOGY.
 
Engler and Prantl system of classification in plant taxonomy
Engler and Prantl system of classification in plant taxonomyEngler and Prantl system of classification in plant taxonomy
Engler and Prantl system of classification in plant taxonomy
 
CALL ON ➥8923113531 🔝Call Girls Kesar Bagh Lucknow best Night Fun service 🪡
CALL ON ➥8923113531 🔝Call Girls Kesar Bagh Lucknow best Night Fun service  🪡CALL ON ➥8923113531 🔝Call Girls Kesar Bagh Lucknow best Night Fun service  🪡
CALL ON ➥8923113531 🔝Call Girls Kesar Bagh Lucknow best Night Fun service 🪡
 
Analytical Profile of Coleus Forskohlii | Forskolin .pptx
Analytical Profile of Coleus Forskohlii | Forskolin .pptxAnalytical Profile of Coleus Forskohlii | Forskolin .pptx
Analytical Profile of Coleus Forskohlii | Forskolin .pptx
 
Luciferase in rDNA technology (biotechnology).pptx
Luciferase in rDNA technology (biotechnology).pptxLuciferase in rDNA technology (biotechnology).pptx
Luciferase in rDNA technology (biotechnology).pptx
 
Physiochemical properties of nanomaterials and its nanotoxicity.pptx
Physiochemical properties of nanomaterials and its nanotoxicity.pptxPhysiochemical properties of nanomaterials and its nanotoxicity.pptx
Physiochemical properties of nanomaterials and its nanotoxicity.pptx
 
Artificial Intelligence In Microbiology by Dr. Prince C P
Artificial Intelligence In Microbiology by Dr. Prince C PArtificial Intelligence In Microbiology by Dr. Prince C P
Artificial Intelligence In Microbiology by Dr. Prince C P
 
Dashanga agada a formulation of Agada tantra dealt in 3 Rd year bams agada tanta
Dashanga agada a formulation of Agada tantra dealt in 3 Rd year bams agada tantaDashanga agada a formulation of Agada tantra dealt in 3 Rd year bams agada tanta
Dashanga agada a formulation of Agada tantra dealt in 3 Rd year bams agada tanta
 
Hubble Asteroid Hunter III. Physical properties of newly found asteroids
Hubble Asteroid Hunter III. Physical properties of newly found asteroidsHubble Asteroid Hunter III. Physical properties of newly found asteroids
Hubble Asteroid Hunter III. Physical properties of newly found asteroids
 
Behavioral Disorder: Schizophrenia & it's Case Study.pdf
Behavioral Disorder: Schizophrenia & it's Case Study.pdfBehavioral Disorder: Schizophrenia & it's Case Study.pdf
Behavioral Disorder: Schizophrenia & it's Case Study.pdf
 
PossibleEoarcheanRecordsoftheGeomagneticFieldPreservedintheIsuaSupracrustalBe...
PossibleEoarcheanRecordsoftheGeomagneticFieldPreservedintheIsuaSupracrustalBe...PossibleEoarcheanRecordsoftheGeomagneticFieldPreservedintheIsuaSupracrustalBe...
PossibleEoarcheanRecordsoftheGeomagneticFieldPreservedintheIsuaSupracrustalBe...
 
Grafana in space: Monitoring Japan's SLIM moon lander in real time
Grafana in space: Monitoring Japan's SLIM moon lander  in real timeGrafana in space: Monitoring Japan's SLIM moon lander  in real time
Grafana in space: Monitoring Japan's SLIM moon lander in real time
 
Boyles law module in the grade 10 science
Boyles law module in the grade 10 scienceBoyles law module in the grade 10 science
Boyles law module in the grade 10 science
 
Natural Polymer Based Nanomaterials
Natural Polymer Based NanomaterialsNatural Polymer Based Nanomaterials
Natural Polymer Based Nanomaterials
 
Is RISC-V ready for HPC workload? Maybe?
Is RISC-V ready for HPC workload? Maybe?Is RISC-V ready for HPC workload? Maybe?
Is RISC-V ready for HPC workload? Maybe?
 
Isotopic evidence of long-lived volcanism on Io
Isotopic evidence of long-lived volcanism on IoIsotopic evidence of long-lived volcanism on Io
Isotopic evidence of long-lived volcanism on Io
 
Scheme-of-Work-Science-Stage-4 cambridge science.docx
Scheme-of-Work-Science-Stage-4 cambridge science.docxScheme-of-Work-Science-Stage-4 cambridge science.docx
Scheme-of-Work-Science-Stage-4 cambridge science.docx
 
Recombination DNA Technology (Nucleic Acid Hybridization )
Recombination DNA Technology (Nucleic Acid Hybridization )Recombination DNA Technology (Nucleic Acid Hybridization )
Recombination DNA Technology (Nucleic Acid Hybridization )
 
All-domain Anomaly Resolution Office U.S. Department of Defense (U) Case: “Eg...
All-domain Anomaly Resolution Office U.S. Department of Defense (U) Case: “Eg...All-domain Anomaly Resolution Office U.S. Department of Defense (U) Case: “Eg...
All-domain Anomaly Resolution Office U.S. Department of Defense (U) Case: “Eg...
 

The Lights Out Puzzle and Its Variations

  • 1. Lights Out Classic Variations of the Lights Out Puzzle The Lights Out Puzzle and Its Variations Pengfei Li School of Computing Clemson University November 30, 2011 Pengfei Li The Lights Out Puzzle and Its Variations
  • 2. Lights Out Classic Variations of the Lights Out Puzzle Outline 1 Lights Out Classic Introduction Solving the Lights Out Classic Initial Observations Linear Algebraic Analysis Solving the Puzzle by Hand 2 Variations of the Lights Out Puzzle Generalizations of the Lights Out Variations of the Game Board Lights Out 2000 Restrictions on the Lights Out Classic Lit-only Lights Out The Toggle Game Pengfei Li The Lights Out Puzzle and Its Variations
  • 3. Lights Out Classic Variations of the Lights Out Puzzle Introduction Solving the Lights Out Classic Introduction - The Goal and Rules A lights out game on iPhonea a Image Source: http://itunes.apple.com What is the “Lights Out Puzzle”? An electronic game firstly released in 1995 5 × 5 array of 25 lighted buttons Each light has 2 states (ON or OFF) The game starts with an initial pattern of lights. Rules When one button is toggled, the lights on it and its neighbors change states. (ON → OFF, or OFF → ON) Buttons on the edges/corners have only 3/2 neighbors. Goal Turn all lights OFF. Use as few steps of toggling as possible. Pengfei Li The Lights Out Puzzle and Its Variations
  • 4. Lights Out Classic Variations of the Lights Out Puzzle Introduction Solving the Lights Out Classic Solving the Lights Out Classic (An Example) Solving a lights out puzzle of the initial pattern with 4 steps. The button with red frame is the one to be toggled in each step. Pattern 1 (initial) Pattern 2 (after step 1) Pattern 3 (after step 2) Pattern 4 (after step 3) All-OFF Pattern (Done!) Pengfei Li The Lights Out Puzzle and Its Variations
  • 5. Lights Out Classic Variations of the Lights Out Puzzle Introduction Solving the Lights Out Classic Questions to Answer... We might be interested in these questions: The 25 lights contribute to 225 different patterns in total. 1 Given a random pattern, is it possible to turn all the lights off? 2 If not, how many patterns are solvable? 3 How to solve a pattern if it is solvable? 4 What is the optimal solution? (The one with minimum steps of toggling) Pengfei Li The Lights Out Puzzle and Its Variations
  • 6. Lights Out Classic Variations of the Lights Out Puzzle Introduction Solving the Lights Out Classic Initial Observations What contributes to the light states? (An experiment) 2 33 0 1 0 0 1 1 111 0 1 1 2 5 0 0 00 3 4 2 3 (Odd) (Even) 1 Initial state 2 Parity of toggling time of each and its neighbors Basic Conclusion 1.1 The set of lights affected is irrelevant to the sequence in which the buttons are toggled. Basic Conclusion 1.2 Toggling a button twice is equivalent to not toggling it at all. (Once is enough!) Pengfei Li The Lights Out Puzzle and Its Variations
  • 7. Lights Out Classic Variations of the Lights Out Puzzle Introduction Solving the Lights Out Classic Further Observation A further conclusion: Solve Restore Basic Conclusion 1.3 If one pattern can be solved by toggling a set of buttons, then starting with the all-OFF pattern and toggling the same set of buttons will restore the original one. Let’s begin the linear algebraic analysis... Pengfei Li The Lights Out Puzzle and Its Variations
  • 8. Lights Out Classic Variations of the Lights Out Puzzle Introduction Solving the Lights Out Classic The Grid Graph & Neighborhood Matrix Consider the 5 × 5 array as a grid graph... Definition 1.1 The neighborhood matrix of a graph is the adjacency matrix plus an identity matrix of the same size: N = A + I. N =                1 1 0 0 0 1 0 . . . 0 1 1 1 0 0 0 1 . . . 0 0 1 1 1 0 0 0 . . . 0 0 0 1 1 1 0 0 . . . 0 0 0 0 1 1 0 0 . . . 0 1 0 0 0 0 1 1 . . . 0 0 1 0 0 0 1 1 . . . 0 ... ... ... ... ... ... ... ... ... 0 0 0 0 0 0 0 . . . 1                All 1s on its diagonal instead of all 0s Each row/column indicates the lights affected Pengfei Li The Lights Out Puzzle and Its Variations
  • 9. Lights Out Classic Variations of the Lights Out Puzzle Introduction Solving the Lights Out Classic Indicator Vectors Definition 1.2 The toggling indicator vector and pattern indicator vector, denoted x and b respectively, are 25 × 1 vectors over Z2 (Z2 = {0, 1}) indicating the sets of buttons to be toggled and the patterns of the 5 × 5 array in row-by-row sequence.       0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 1 0 1 0 0 0 0 0 1             0 0 0 0 0 1 0 0 0 0 1 0 0 1 0 0 1 0 1 0 0 1 0 0 1       x = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1)T b = (0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1)T Pengfei Li The Lights Out Puzzle and Its Variations
  • 10. Lights Out Classic Variations of the Lights Out Puzzle Introduction Solving the Lights Out Classic What is the product of N and x over Z2? We use and to represent XOR and matrix multiplication over Z2. Suppose x = (1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)T. N x =                1 1 0 0 0 1 0 . . . 0 1 1 1 0 0 0 1 . . . 0 0 1 1 1 0 0 0 . . . 0 0 0 1 1 1 0 0 . . . 0 0 0 0 1 1 0 0 . . . 0 1 0 0 0 0 1 1 . . . 0 0 1 0 0 0 1 1 . . . 0 ... ... ... ... ... ... ... ... ... 0 0 0 0 0 0 0 . . . 1                               1 0 1 0 1 0 0 ... 0                =                1 1 0 0 0 1 0 ... 0                               0 1 1 1 0 0 0 ... 0                               0 0 0 1 1 0 0 ... 0                =                1 0 1 0 1 1 0 ... 0                The product is the XOR of some columns of N selected by x. It indicates the lights whose states changed (the pattern restored by the toggling of x). Pengfei Li The Lights Out Puzzle and Its Variations
  • 11. Lights Out Classic Variations of the Lights Out Puzzle Introduction Solving the Lights Out Classic Basic Conclusion of Solvability Together with previous conclusions, we have the following: Theorem 1.1 A pattern of the lights out puzzle is solvable iff there exists a vector x such that N x = b where b is the indicator vector of the pattern. Now we have reduced the problem to the solvability of a system of linear equations. Although all operations are over Z2, theorems in linear algebra still follow. (1) Given a random pattern, is it possible to turn all the lights off? No. Since det (N) = 0, the system of linear equations does not always have a solution. (2), (3) and (4) will be answered after a few more analysis on N... Pengfei Li The Lights Out Puzzle and Its Variations
  • 12. Lights Out Classic Variations of the Lights Out Puzzle Introduction Solving the Lights Out Classic Solving the System of Equations N x = b We perform elementary row operations on N until it reaches reduced row echelon form E. N ∼ E =              1 0 0 0 . . . 0 0 1 0 1 0 0 . . . 0 1 0 0 0 1 0 . . . 0 1 1 0 0 0 1 . . . 0 1 0 ... ... ... ... ... ... ... ... 0 0 0 0 . . . 1 1 1 0 0 0 0 . . . 0 0 0 0 0 0 0 . . . 0 0 0              = I23×23 M23×2 O2×23 O2×2 (rank (N) = 23) N x = b has a solution ⇔ b belongs to Col N ⇔ b belongs to (Nul NT)⊥ ⇔ b belongs to (Nul N)⊥ ⇔ b belongs to (Nul E)⊥ ⇔ b ⊥ an orthogonal basis of Nul E Pengfei Li The Lights Out Puzzle and Its Variations
  • 13. Lights Out Classic Variations of the Lights Out Puzzle Introduction Solving the Lights Out Classic Solvability Conclusion by Linear Algebra An orthogonal basis for Nul E from last 2 columns of E = I23×23 M23×2 O2×23 O2×2 Replacing the zero matrix O2×2 with an identity matrix I2×2, we get an orthogonal basis: n1 = (0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0)T n2 = (1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1)T n1 and n2 can be used as test vectors. Putting all these together, we have: Theorem 1.2 A pattern of the lights out puzzle is solvable iff b ⊥ n1 and b ⊥ n2 where b is the indicator vector of the pattern. Pengfei Li The Lights Out Puzzle and Its Variations
  • 14. Lights Out Classic Variations of the Lights Out Puzzle Introduction Solving the Lights Out Classic Test the Solvability (An Example) We use to represent the dot product over Z2. (a ⊥ b ⇔ a b = 0) c n1 = 1 c n2 = 0 c ⊥ n1 m n1 = 0 m n2 = 0 m ⊥ n1 and m ⊥ n2 The pattern “C” is not solvable, but the pattern “M” is! Pengfei Li The Lights Out Puzzle and Its Variations
  • 15. Lights Out Classic Variations of the Lights Out Puzzle Introduction Solving the Lights Out Classic How Many Patterns Are Solvable? N x = b has a solution ⇔ rank (N|b) = rank (N) = 23 (How to satisfy?) (N|b) =            1 1 0 . . . 0 0 0 b1 1 1 1 . . . 0 0 0 b2 0 1 1 . . . 0 0 0 b3 ... ... ... ... ... ... ... ... 0 0 0 . . . 1 1 0 b23 0 0 0 . . . 1 1 1 b24 0 0 0 . . . 0 1 1 b25            ∼            1 0 0 . . . 0 0 1 e1 0 1 0 . . . 0 1 0 e2 0 0 1 . . . 0 1 1 e3 ... ... ... ... ... ... ... ... 0 0 0 . . . 1 1 1 e23 0 0 0 . . . 0 0 0 0 0 0 0 . . . 0 0 0 0            If we want rank (N|b) to be 23, and we have assigned b1, b2, . . . , b23 with values of 0s and 1s, only one pair of (b24, b25) in {(0, 0), (0, 1), (1, 0), (1, 1)} satisfies! 23 of the lights are free, 2 lights are constrained. i.e. Only 1/4 of all patterns are solvable. There are 223 solvable patterns in total. Pengfei Li The Lights Out Puzzle and Its Variations
  • 16. Lights Out Classic Variations of the Lights Out Puzzle Introduction Solving the Lights Out Classic How to Solve for x in N x = b ? 1 Gauss-Jordan elimination on (N|b) 2 N x = b ⇔ x = N−1 b if N is invertible (rank (N) = 23) A trick: Compute the pseudo-inverse of N: Gauss-Jordan elimination on (N|I)25×50 N25×25 I25×25 ∼ E25×25 ˆN25×25 Then ˆN is the pseudo-inverse of N. Algorithm 1.1 For any solvable pattern b, x = ˆN b gives one solution of the pattern. How to find the optimal solution? This is an O(n2) algorithm. Can we have a better one? Pengfei Li The Lights Out Puzzle and Its Variations
  • 17. Lights Out Classic Variations of the Lights Out Puzzle Introduction Solving the Lights Out Classic Stable Togglings Since n1, n2 ∈ Nul N and Nul N = {x ∈ {0, 1}25 | N x = 0}, n1 and n2 indicate the “stable” togglings! 0 (trivial) n1 n2 n1 n2 These are all the linear combinations of n1 and n2 over Z2. i.e. Only 4 stable togglings exist. For a solvable pattern, there are 4 solutions. The optimal one is one of them. From the all-OFF pattern, every 4 different togglings generate the same pattern. Pengfei Li The Lights Out Puzzle and Its Variations
  • 18. Lights Out Classic Variations of the Lights Out Puzzle Introduction Solving the Lights Out Classic How Many Steps Needed at Most? cba a d ad b b d b d a d a c b a b c a a bc b Partition n1 n2 n1 n2 Suppose that the optimal solution x has X buttons to be toggled. X = A + B + C + D x n1 has (8 − A) + (8 − B) + C + D buttons.    X ≤ (8 − A) + (8 − B) + C + D X ≤ (8 − A) + B + (4 − C) + D X ≤ A + (8 − B) + (4 − C) + D D ≤ 5 ⇒ max (A + B + C + D) = 15 Theorem 1.3 Every solvable pattern of the lights out puzzle can be solved within 15 steps. Pengfei Li The Lights Out Puzzle and Its Variations
  • 19. Lights Out Classic Variations of the Lights Out Puzzle Introduction Solving the Lights Out Classic What Have We Done? We have answered all the questions. We know the solvability, the number of solutions and the way to find the optimal one. But, how to solve the puzzle by hand? Also, we prefer an algorithm of O(n) than of O(n2). Pengfei Li The Lights Out Puzzle and Its Variations
  • 20. Lights Out Classic Variations of the Lights Out Puzzle Introduction Solving the Lights Out Classic Testing the Solvability by Hand Continue considering the 3 non-trivial stable togglings... When toggling a button, numbers of the “blue” buttons affected: 0, 2, 4 (Even) i.e. Pattern is solvable ⇒ number of lit buttons overlapped with the “blue” buttons is even. The other direction of this proposition can also be proved. Actually, only 2 of the 3 non-trivial stable togglings need to be tested. Pengfei Li The Lights Out Puzzle and Its Variations
  • 21. Lights Out Classic Variations of the Lights Out Puzzle Introduction Solving the Lights Out Classic Testing the Solvability by Hand (An Example) The Pattern “C” Test Patterns Overlapped |{c} ∩ {n1}| = 2 (Even) |{c} ∩ {n1 n2}| = 5 (Odd) Result: Not solvable! Pengfei Li The Lights Out Puzzle and Its Variations
  • 22. Lights Out Classic Variations of the Lights Out Puzzle Introduction Solving the Lights Out Classic Chasing the Lights Down What is the universal way of solving all 223 solvable patterns? A trick: Chasing the lights Down: All lit buttons can only be in the last row. In the last row, 3 lights are free, 2 lights are constrained. (if solvable) i.e. We have merged all the 223 cases into 23 = 8 cases. Pengfei Li The Lights Out Puzzle and Its Variations
  • 23. Lights Out Classic Variations of the Lights Out Puzzle Introduction Solving the Lights Out Classic The 8 Cases after Chasing These are the 8 possible last-row patterns after chasing: The other 25 − 8 = 24 last-row patterns are not solvable! After chasing, we can decide which case the pattern is in. In the first case: We have done! In the other 7 cases: Minutely adjust the pattern to shift it to the first case. Pengfei Li The Lights Out Puzzle and Its Variations
  • 24. Lights Out Classic Variations of the Lights Out Puzzle Introduction Solving the Lights Out Classic The Algorithm Algorithm 1.2 Number the rows 1-5, the columns A-E. 1 Chase the lights down to make all lit lights in row 5. 2 If the light at A5 is on then toggle D1 and E1. 3 If the light at B5 is on then toggle B1 and E1. 4 If the light at C5 is on then toggle D1. 5 Chase the lights down again until all lights off. 6 Delete the redundant buttonsa, and then XOR the solution with 3 non-trivial stable togglings to get the optimal one. a The buttons been toggled twice E1D1B1 C5B5A5 This algorithm is in O(n). Pengfei Li The Lights Out Puzzle and Its Variations
  • 25. Lights Out Classic Variations of the Lights Out Puzzle Outline 1 Lights Out Classic Introduction Solving the Lights Out Classic Initial Observations Linear Algebraic Analysis Solving the Puzzle by Hand 2 Variations of the Lights Out Puzzle Generalizations of the Lights Out Variations of the Game Board Lights Out 2000 Restrictions on the Lights Out Classic Lit-only Lights Out The Toggle Game Pengfei Li The Lights Out Puzzle and Its Variations
  • 26. Lights Out Classic Variations of the Lights Out Puzzle Generalizations of the Lights Out Restrictions on the Lights Out Classic Variations of the Game Board (Examples) Different game board shapes Last-Out Lights Out Cube Image Source: http://www.powerstrike.net Different neighborhood definitions 4 neighbors 8 neighbors “X” neighbors “O” neighbors None of these variations makes the game harder! Just change another neighborhood matrix N and perform the similar analysis. Pengfei Li The Lights Out Puzzle and Its Variations
  • 27. Lights Out Classic Variations of the Lights Out Puzzle Generalizations of the Lights Out Restrictions on the Lights Out Classic Lights Out 2000 T( ) = T( ) = T( ) = In lights out 2000, each light has 3 states. It is a modulo 3 game instead of modulo 2. Performing the similar analysis (changing to mod 3), we can get: There are 22 free lights, 3 constrained lights. 322 = 31, 381, 059, 609 solvable patterns exist. 33 = 27 different stable togglings exist. Every solvable pattern can be solved within 24 steps. An O(n2) algorithm by solving a system of linear equations An O(n) algorithm by “chasing the lights down” Pengfei Li The Lights Out Puzzle and Its Variations
  • 28. Lights Out Classic Variations of the Lights Out Puzzle Generalizations of the Lights Out Restrictions on the Lights Out Classic Conclusions of the Generalized Lights Out For any generalizations of the lights out puzzle, if Number of buttons: m Number of states of each button: s Nullitya of the neighborhood matrix: n Then Number of free lights: m − n Number of constrained lights: n Number of all patterns: sm Number of solvable patterns: sm−n Number of different stable togglings: sn For some game board shapes, we can consider rotations and mirrors to make it simpler. a Nullity is the dimension of the null space Pengfei Li The Lights Out Puzzle and Its Variations
  • 29. Lights Out Classic Variations of the Lights Out Puzzle Generalizations of the Lights Out Restrictions on the Lights Out Classic Lit-only Lights Out This game is a little tricky. It is the lights out classic with the restriction: Restriction 2.1 Only lit buttons are allowed to be toggled: . . . If you toggle an unlit buttons, the pattern stays unchanged. Theorem 2.1 A pattern in lit-only lights out can be solved iff it can be solved in lights out classic. Key points: 1 The toggling sequence is important! 2 We might need to toggle some of the buttons more than once. 3 We might need more steps than solving the same pattern in lights out classic. Pengfei Li The Lights Out Puzzle and Its Variations
  • 30. Lights Out Classic Variations of the Lights Out Puzzle Generalizations of the Lights Out Restrictions on the Lights Out Classic The Algorithm for One Solution Algorithm 2.1 1 Perform the classic algorithm until you’re not able to take more steps. 2 Find a path from one nearest lit button (source button) if existsa to the button to be toggled (destination button). 3 Toggle the following buttons: 1 The source button 2 Buttons on the path (auxiliary buttons) in the path sequence 3 The destination button 4 The auxiliary buttons in some sequenceb 5 The source button 4 Repeat 1-3 until all lights off. a If no lit button exists, we have done! b You are always able do that. Just keep toggling a lit one then a sequence is found. Pengfei Li The Lights Out Puzzle and Its Variations
  • 31. Lights Out Classic Variations of the Lights Out Puzzle Generalizations of the Lights Out Restrictions on the Lights Out Classic The Algorithm for the Optimal Solution ... ... ... ... ... ... ... ... The patterns graph Build a directed patterns graph with 223 nodes. Each node represents a solvable pattern. Each edge represents that one pattern is reachable from another by one step of toggling. Only one edge exists between a pair of nodes. The out-degree of one node is the number of lit buttons. The out-degree of the all-OFF pattern node is 0. Algorithm 2.2 Perform Breadth First Search on the patterns graph from current pattern until the node with 0 out-degree is reached. This is an O(2n) algorithm! Pengfei Li The Lights Out Puzzle and Its Variations
  • 32. Lights Out Classic Variations of the Lights Out Puzzle Generalizations of the Lights Out Restrictions on the Lights Out Classic The Toggle Game It’s a more difficult game with the following restriction: Restriction 2.2 You have to alternatively toggle one lit button and one unlit button: . . . or . . . If you toggle a wrong button, the pattern stays unchanged. Key points: The last step is always toggling a lit pattern to turn all lights off. The first sequence has an odd number of steps, the second has an even number. Since all solutions have the same parity, you must decide carefully which button (lit/unlit) for the first step, or you’ll never be able to solve it. Pengfei Li The Lights Out Puzzle and Its Variations
  • 33. Lights Out Classic Variations of the Lights Out Puzzle References Marlow Anderson and Todd Feil. Turing lights out with linear algebra. Mathematics Magazine, 71(4):300–303, 1998. Peter J. Slater Ashok T. Amin and Guo hui Zhang. Parity dimension for graphs - a linear algebraic approach. Linear and Multilinear Algebra, 50(4):327–342, 2002. Alexander Giffen and Darren B. Parker. On generalizing the “lights out” game and a generalization of parity domination, 2009. Jaap Scherphuis. Jaap’s puzzle page (lights out). http://www.jaapsch.net/puzzles/lights.htm. [Online; 2010-01-31]. Jaap Scherphuis. Jaap’s puzzle page (the mathematics of lights out). http://www.jaapsch.net/puzzles/lomath.htm. [Online; 2009-09-20]. Pengfei Li The Lights Out Puzzle and Its Variations
  • 34. Lights Out Classic Variations of the Lights Out Puzzle The End That’s All Thanks! Pengfei Li The Lights Out Puzzle and Its Variations