On this page
Lights Out is a grid of lit buttons. Press one and it flips, along with its neighbours above, below, left and right; the goal is to turn every light off. In Mathematics Magazine in 1998, Marlow Anderson and Todd Feil showed that a complete strategy for Tiger Electronics' 5×5 game needs only Gauss–Jordan elimination and a few facts about column and null spaces, all done modulo 2.
Why is Lights Out a linear algebra problem?
Two observations in Anderson and Feil's paper do the work. Pressing a button twice is the same as not pressing it, so each button is pressed once or not at all. And a light's final state depends only on whether it and its neighbours were pressed an odd or even number of times, so order does not matter.
That is arithmetic in GF(2), the smallest finite field, where 1 + 1 = 0. Write the lit pattern as a vector b, with 1 for each light that is on, and a strategy as a vector x, with 1 for each button you press. Each press adds one column of a fixed matrix A, so the presses change the board by Ax.
Clearing the board means b + Ax = 0, and since −1 = 1 mod 2, that is Ax = b. A pattern can be cleared exactly when b lies in the column space of A.
How do you solve a 3×3 Lights Out by hand?
Number the buttons 1, 2, 3 along the top row, 4, 5, 6 in the middle and 7, 8, 9 at the bottom. Light 1 gives the equation x1 + x2 + x4 = b1 and light 5 gives x2 + x4 + x5 + x6 + x8 = b5.
Take the top row lit, b = (1, 1, 1, 0, 0, 0, 0, 0, 0), and chase the lights down, the row-by-row method Anderson and Feil also describe:
Press the button below each lit light in row 1: buttons 4, 5 and 6. Row 1 goes dark; lights 5, 7, 8 and 9 come on.
Only light 5 is on in row 2, so press button 8. It flips lights 5, 7, 8 and 9, and the board is dark.
Check: x = buttons 4, 5, 6 and 8. Lights 1, 2 and 3 are each touched once, so they flip. Light 5 is touched four times and every other light twice, so they stay off. Ax = b.
Is this the only answer? In Anderson and Feil's table the 3×3 matrix has a null space of dimension 0, so A is invertible mod 2 and each of the 2⁹ = 512 patterns has exactly one solution without repeated presses (Mathematics Magazine). Chasing can leave lights in the bottom row; solving the nine equations by elimination always works.
Why can't some 5×5 Lights Out patterns be solved?
On the 5×5 board A is a 25 × 25 matrix, and Anderson and Feil found that it has rank 23, not 25 (Mathematics Magazine, 1998). By the rank–nullity theorem, its null space has dimension 2. The paper draws two consequences:
Only one quarter of the 2²⁵ patterns are solvable, about 8.4 million of 33.6 million.
Each solvable pattern has exactly four press-sets that clear it: x, x + n1, x + n2 and x + n1 + n2, where n1 and n2 span the null space.
Its test: a pattern is solvable if and only if it is perpendicular, mod 2, to n1 and n2. The two null patterns, row by row:
n1: 01110, 10101, 11011, 10101, 01110
n2: 10101, 10101, 00000, 10101, 10101
Count your lit lights that sit on a 1 of n1, then those on a 1 of n2. If both counts are even, the pattern can be cleared; if either is odd, nothing will clear it. Why: A is symmetric and An1 = An2 = 0, so no press changes either count's parity, and a dark board has both counts at zero.
A single lit corner sits on a 1 of n2, an odd count, so it can never be turned off. A lone centre light sits on 0 in both and is solvable, and the fully lit board, with 16 lights on n1 and 12 on n2, both even, is solvable too.
That is the argument behind why the 15 puzzle with 14 and 15 swapped can't be solved. Board size matters too: in the same table of Anderson and Feil, the 4×4 board has a null space of dimension 4, while every 6×6 pattern is solvable.
How can you practise Lights Out algebra?
Draw a 3×3 pattern on paper, chase it, then check Ax = b by counting touches.
Write the nine equations for another pattern and solve them by elimination mod 2.
On a 5×5 grid, run the n1 and n2 parity counts on three patterns before playing them.
If rank or null space is the step that slips, the Fermi Concept Library covers every concept in mathematics, and the Fermi Problem Library has a step-by-step solver that explains the reasoning.



