# the lights out puzzle and its variations

Post on 15-Jul-2015

458 views

Category:

## Science

1 download

Embed Size (px)

TRANSCRIPT

• Lights Out ClassicVariations of the Lights Out Puzzle

The Lights Out Puzzle and Its Variations

Pengfei Li

School of ComputingClemson University

November 30, 2011

Pengfei Li The Lights Out Puzzle and Its Variations

• Lights Out ClassicVariations of the Lights Out Puzzle

Outline

1 Lights Out ClassicIntroductionSolving the Lights Out Classic

Initial ObservationsLinear Algebraic AnalysisSolving the Puzzle by Hand

2 Variations of the Lights Out PuzzleGeneralizations of the Lights Out

Variations of the Game BoardLights Out 2000

Restrictions on the Lights Out ClassicLit-only Lights OutThe Toggle Game

Pengfei Li The Lights Out Puzzle and Its Variations

• Lights Out ClassicVariations of the Lights Out Puzzle

IntroductionSolving the Lights Out Classic

Introduction - The Goal and Rules

A lights out game on iPhonea

aImage Source: http://itunes.apple.com

What is the Lights Out Puzzle?

An electronic game firstly released in 19955 5 array of 25 lighted buttonsEach 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 neighborschange 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 ClassicVariations of the Lights Out Puzzle

IntroductionSolving 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 ClassicVariations of the Lights Out Puzzle

IntroductionSolving 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 ClassicVariations of the Lights Out Puzzle

IntroductionSolving 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 ClassicVariations of the Lights Out Puzzle

IntroductionSolving 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-OFFpattern and toggling the same set of buttons will restore the original one.

Lets begin the linear algebraic analysis...

Pengfei Li The Lights Out Puzzle and Its Variations

• Lights Out ClassicVariations of the Lights Out Puzzle

IntroductionSolving 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 theadjacency matrix plus an identity matrix ofthe same size: N = A + I.

N =

1 1 0 0 0 1 0 . . . 01 1 1 0 0 0 1 . . . 00 1 1 1 0 0 0 . . . 00 0 1 1 1 0 0 . . . 00 0 0 1 1 0 0 . . . 01 0 0 0 0 1 1 . . . 00 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 ClassicVariations of the Lights Out Puzzle

IntroductionSolving 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 thepatterns of the 5 5 array in row-by-row sequence.

0 0 0 0 00 0 0 0 01 0 0 0 00 1 0 1 00 0 0 0 1

0 0 0 0 01 0 0 0 01 0 0 1 00 1 0 1 00 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 ClassicVariations of the Lights Out Puzzle

IntroductionSolving 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 . . . 01 1 1 0 0 0 1 . . . 00 1 1 1 0 0 0 . . . 00 0 1 1 1 0 0 . . . 00 0 0 1 1 0 0 . . . 01 0 0 0 0 1 1 . . . 00 1 0 0 0 1 1 . . . 0...

......

......

......

. . ....

0 0 0 0 0 0 0 . . . 1

1010100...0

=

1100010...0

0111000...0

0001100...0

=

1010110...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 ClassicVariations of the Lights Out Puzzle

IntroductionSolving 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 = bwhere 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 ClassicVariations of the Lights Out Puzzle

IntroductionSolving 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 10 1 0 0 . . . 0 1 00 0 1 0 . . . 0 1 10 0 0 1 . . . 0 1 0...

......

.... . .

......

...0 0 0 0 . . . 1 1 10 0 0 0 . . . 0 0 00 0 0 0 . . . 0 0 0

=

[I2323 M232O223 O22

](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 ClassicVariations of the Lights Out Puzzle

IntroductionSolving the Lights Out Classic

Solvability Conclusion by Linear Algebra

An orthogonal basis for Nul E from last 2 columns of E =

[I2323 M232O223 O22

]Replacing the zero matrix O22 with an identity matrix I22, 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 indicatorvector of the pattern.

Pengfei Li The Lights Out Puzzle and Its Variations

• Lights Out ClassicVariations of the Lights Out Puzzle

IntroductionSolving 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 = 1c

n2 = 0

c 6 n1

m

n1 = 0m

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 ClassicVariations of the Lights Out Puzzle

IntroductionSolving 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 b11 1 1 . . . 0 0 0 b20 1 1 . . . 0 0 0 b3...

......

. . ....

......

...0 0 0 . . . 1 1 0 b230 0 0 . . . 1 1 1 b240 0 0 . . . 0 1 1 b25

1 0 0 . . . 0 0 1 e10 1 0 . . . 0 1 0 e20 0 1 . . . 0 1 1 e3...

......

. . ....

......

...0 0 0 . . . 1 1 1 e230 0 0 . . . 0 0 0 00 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 and1s, 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 solvab