Sie sind auf Seite 1von 5

Turning Lights Out with Linear Algebra Author(s): Marlow Anderson and Todd Feil Source: Mathematics Magazine,

Vol. 71, No. 4 (Oct., 1998), pp. 300-303 Published by: Mathematical Association of America Stable URL: . Accessed: 29/04/2013 09:29
Your use of the JSTOR archive indicates your acceptance of the Terms & Conditions of Use, available at .

JSTOR is a not-for-profit service that helps scholars, researchers, and students discover, use, and build upon a wide range of content in a trusted digital archive. We use information technology and tools to increase productivity and facilitate new forms of scholarship. For more information about JSTOR, please contact

Mathematical Association of America is collaborating with JSTOR to digitize, preserve and extend access to Mathematics Magazine.

This content downloaded from on Mon, 29 Apr 2013 09:29:58 AM All use subject to JSTOR Terms and Conditions



Turning Lights Out withLinear Algebra

Colorado College CO 80903 Colorado Springs,

Denison University OH 43023 Granville,



The game LightsOut, commercially of a availablefrom consists TigerElectronics, 5 x 5 arrayof 25 lightedbuttons; each lightmaybe on or off.A move consists of a singlebutton. stateof the light on the button pushing Doing so changesthe on/off pushed,and of all itsvertical and horizontal Givenan initial neighbors. configuration of lights whichare turned on, the objectis to turnout all the lights. A completestrategy forthe game can be obtainedusinglinearalgebra,requiring of Gauss-Jordan and some factsabout the columnand elimination onlyknowledge null spaces of a matrix. All calculations are done modulo2. We makesome initial observations. 1. Pushing a button it at all. Hence, foranygiven twiceis equivalent to notpushing we need consideronlysolutions in whicheach buttonis pushed configuration, no morethanonce. 2. The stateofa button dependsonlyon howoften (whether evenor odd) it and its are pushed have been pushed.Hence, the orderin whichthe buttons neighbors is immaterial. We willrepresent the stateof each lightby an elementof Z2, the fieldof integers in the ith row modulo2; 1 foron, and 0 foroff. We willdenotethe stateof the light a and jth columnby bi j, an elementof Z2, and the entirearray by 25 x 1 column vectorb, withentries orderedas follows:

b = (bI,I, bI,2,- , bl,5, b2,1,


of the array. We willcall such a vectora configuration (T standsfortranspose). thathas a button vector Pressing changesthe configuration by addingto b a vector l's at the locationof the buttonand its neighbors and O's elsewhere.The orderof a strategy so we may represent pushingbuttonsmakes no differences, by another 25 X I columnvectorx, where xi is 1 if the (i,j) buttonis to be pushed,and 0 otherwise. b is obtained withall thelights out and configuration If we start bystrategy x, then
b 1=XI1,
b1,2 b1,3 = = X1,I xI2

+ X1,2

+ X1,3 + X2,2,

+ X1,3

+ X1,4

+ X2,3-

This content downloaded from on Mon, 29 Apr 2013 09:29:58 AM All use subject to JSTOR Terms and Conditions

VOL. 71, NO. 4, OCTOBER 1998


x is the to checkthatthe resultb ofthe strategy it is straightforward More generally, productAx = b, where A is the 25 X 25 matrix: matrix 0 0 I1 0 B I A= I B I 0 0 B I I O O I B) of all zeros,and B is the 0 is the 5 X 5 matrix matrix, here I is the 5 x 5 identity B I 0 0 O
matrix I 1 I 1 0 1 0 0 0 0



1 1

0 O

1 0

1 1

too. and so A is symmetric matrix, Note that B is a symmetric if thereexistsa b, we will saythatb is winnrable configuration Givenan arbitrary is as follows: in b. The keyobservation x to turnout all the lights strategy thenstarting with is pushedto createa configuration, If a set of buttons willturnthelights set ofbuttons thesamne and pressing thatconfiguration out. in b, we need to solveb = Ax. Thus, out all thelights to turn Thatis,to finda strategy b is winnableif and onlyif it belongsto the columnspace of the a configuration by Col( A). matrix A; we denotethe latter on A. This would be elimination Gauss-Jordan To analyzeCol(A), we perform capable algebrasystem tediousto perform by hand,but is easierusinganycomputer will do the job. withentriesfromZ2; Maple or Mathematica matrices of handling and R is echelonform, willyieldRA = E, whereE is the Gauss-Jordan Gauss-Jordan rowoperations. whichperform the reducing matrices the productof the elementary We illuminating. and not particularly formidable, The matricesR and E are rather will not displaythemhere but invitethe readerto calculatethemusinga favorite algebrasystem. computer E is of rank23, withtwofree we see thatthe matrix Havingdone thiscalculation, of E are Indeed,thelasttwocolumns variablesX5,4 and x5,5 in thelasttwocolumns.
(O, 1, 1, 1,0, 1,0, 1,0, 1, 1, 1,0, 1, 1, 1,O, 1,O, 1,O, 1, 1,O,0) T


and so Col(A) equals the rowspace of A, denoted matrix, Now A is a symmetric of the nullspace of A (denoted complement Row(A). But Row(A) is the orthogonal Null(A)), which in turn equals Null(E). So, to describe Col( A), we need only a basis forNull(E). determine basis for it is easy to findan orthogonal echelonform, Since E is in Gauss-Jordan the lasttwocolumnsof E: Null(E) by examining
__> = (nl nl 1, 1, 1, 0, 1, 1, nl n 1, 1, 1, 0,1, 1, 1, nl , nl, T 1, 1, n

This content downloaded from on Mon, 29 Apr 2013 09:29:58 AM All use subject to JSTOR Terms and Conditions





Putting thistogether, we have the following: to the THEOREM 1. A configuration b is winnable ifand onlyifb is perpendicular two vectors nc arnd n2' Therefore, to see ifa configuration is winnable, we simply compute the dotproduct of thatconfiguration withn' and n2. For example, consider below the configurations (whichwe have shaped as 5 X 5 arrays):

f= 0 1 0 1 0
0 I 1 0 1 0 0 0 1 0

1 0

0 1

00 00


= 0 1 1 0 1.
0 I 1 0 0 0 0 0 0 0

0 0

0 1

1 0 0 0

We wouldliketo findone of the Suppose now thatb is a winnableconfiguration. fourstrategies we may x forwhich Ax'= b. But sincewe need onlyfindone solution, as well set the twofreevariablesx5,4 and x55 equal to zero. In thiscase x= 137 So, = RAx= Rb. Explicitly, we have a winning x= Ex5 strategy givenby x = Rb. We thus have the following theorem:
THEOREM 2. Suppose that b is a winnableconfiguration. Then thefour winning strategies for b are

x+ n, x + `2 and x + n- + n2 are also winning strategies.

Then f is winnable, while g is not (g is notperpendicular to n2). from Since the dimension ofthenullspace is 2, and the scalarfieldis Z2, it follows this theoremthat of the 225 possible configurations, of them are only one-fourth if b is a winnable withwinning winnable. x, then Furthermore, configuration strategy



+ ni,


+ n2,


+ n + n2'

To find a winning We observed above thattheconfiguration f is winnable. strategy, we computeRf (wherewe reshapef as a columnvector): Rf= (0,0, ,1, 0,0,0,0,0, 1,0,0,0,0, 1,0, 1,,0,0,0, O,,0,0,0)T. this This theoremgives our solutionsin closed, computableform.Admittedly, is tediousto do byhand,preserving thegame'sappeal. We can do better computation if we proceed algorithmically. thancompleting the entirecomputation, For suppose forthe first row (thatis, the first fiveentriesin the we onlycomputethe strategy out thesemoves;Theorem2 saysthatno moremovesin columnRb). We thencarry We thenlook to see ifthereare anylights on in the first the first roware necessary. is to pushthe row.The onlywayto turntheseout,usingmovesin the lastfourrows, whichis on. Havingnow determined a strategy button below each light immediately the two we then move on to each successive row in the same for first rows, way. to an n X n array of lights. One can proceed in a LightsOut can be generalized is the mannersimilarto the way we solved the 5 X 5 case. What is interesting matrices of the null space of the corresponding forvariousvalues of n dimension the results. (we call these n2 x n2 matricesAn); the table below summarizes

This content downloaded from on Mon, 29 Apr 2013 09:29:58 AM All use subject to JSTOR Terms and Conditions

VOL. 71, NO. 4, OCTOBER 1998


configuration is winnable ofthenullspace is zero,every Of courseifthe dimension are pressedmorethanonce). We haven'tspent and the solution unique(ifno buttons puzzles,but theymustbe verydifficult! anytimetrying to solvesome of theselarger

2 3 4 5 6 7 8 9 10 11

Dimension ofNull(A,,) 0 0 4 2 0 0 0 8 0 6

12 13 14 15 16 17 18 19 20 21

Dimension ofNull(A,,) 0 0 4 0 8 2 0 16 0 0

natural is to considerLightsOut on a torus;thatis, lights A further generalization for on thebottom row,and likewise on thetop roware considered of lights neighbors and rightmost columns. This "wraparound"changesthe matrices theleftmost A,I,of course.(We leave thisas an exerciseforthe reader.)Here are some corresponding results forthe game on toriofvarioussizes:

2 3 4 5 6 7 8 9 10 11

Dimension ofNull(An) 0 4 0 8 8 0 0 4 16 0

12 13 14 15 16 17 18 19 20 21

Dimension ofNull(A,,) 16 0 0 12 0 16 8 0 32 4

on wiiting forhis suggestions thispaper. to our colleagueJohn Watkins AcknowledgmentOur thanks

This content downloaded from on Mon, 29 Apr 2013 09:29:58 AM All use subject to JSTOR Terms and Conditions