Skip to content
Adrien Hubert

Lights Out, on five by five.

Click any cell. That cell flips, and so do its four cardinal neighbours. The goal is the boring one: every light off. The interesting part lives in the maths under the board.

Moves 0
Lights on 0
Status Empty

The puzzle as a linear system

Number the cells from 0 to 24. Build a 25 by 25 matrix A over the field with two elements, where A[i][j] = 1 when pressing button j would toggle cell i. That happens when j = i or when j is a cardinal neighbour of i. The order in which you press buttons does not matter, and pressing the same button twice cancels out, so the only thing the board cares about is the parity of presses per cell.

Reading a board as a vector b of 25 bits, finding a click set is the linear system Ax = b (mod 2). Gauss-Jordan elimination over GF(2) is the same dance as over the reals, but cheaper: addition is XOR and there are no fractions to chase.

Why some boards have no solution

On a five by five board, A has rank 23, not 25. Its null space has dimension two, so there are four vectors that satisfy Ak = 0: the zero vector and three non-trivial patterns of cells. Press any non-trivial kernel pattern and the board stays exactly as it was. Those are the so-called quiet patterns.

Because the kernel has four elements, the set of reachable boards has 223 elements out of 225, which is a quarter of all 33 554 432 possible boards. The other three quarters are unreachable from all-off, and equally unreachable from all-on. The Random board button below only ever samples the solvable quarter, by scrambling the empty board with random presses rather than flipping cells directly.

The same kernel that blocks three quarters of boards also gives you redundancy. Any solution x can be combined with any element of the kernel to produce another valid solution. The hint tries all four cosets and picks the one with the fewest presses.

Sources

The kernel rank result for the standard five by five board is given in Anderson and Feil, Turning Lights Out with Linear Algebra, Mathematics Magazine 71:4 (1998), 300-303. Tiger Electronics released the original handheld game in 1995.