How to use the Lights Out solver
Choose the size of your board (the classic game is 5 x 5), then tap every light that is on. Press Solve: the lights you need to press get a ring. Press each ringed light once, in any order. You can do it on your own puzzle, or switch to Play and tap the ringed lights here to watch the board go dark. Random puzzle makes a solvable board to practice on.
The rules
Pressing a light switches it and its neighbors directly above, below, left and right (not the diagonals). Lights on the edge have fewer neighbors. The goal is to switch every light off.
How the solver works
Two facts make Lights Out a math problem rather than a search. First, the order of presses does not matter: each light just ends up switched once for every press that touches it. Second, pressing the same light twice does nothing. So a solution is simply a set of lights, each pressed once.
That turns the board into a system of equations, one per light: the presses touching that light must add up to an odd number if it is on, and an even number if it is off. The solver solves this system with Gaussian elimination in arithmetic where 1 + 1 = 0 (called GF(2)), the same method you learn for ordinary equations. It runs in a few milliseconds for any size here.
Why some boards cannot be solved
On some board sizes there are quiet patterns: sets of presses that change nothing at all, because every light they touch is switched an even number of times. The solver computes them for each size. The 5 x 5 board has 2 independent quiet patterns, which has two consequences:
- Only 1 in 4 arrangements of lights can be solved. Every press switches an even number of lights inside each quiet pattern, so if a board has an odd number of lit lights inside one, that can never change, and the board can never go dark. A single lit corner is the simplest example.
- Every solvable 5 x 5 board has exactly 4 solutions (add a quiet pattern to a solution and you get another). The solver compares all four and shows the one with the fewest presses.
Sizes differ a lot: 3 x 3, 6 x 6, 7 x 7, 8 x 8 and 10 x 10 have no quiet patterns, so every board is solvable with exactly one solution, while 4 x 4 has 4 and 9 x 9 has 8. If your board comes out unsolvable, the solver outlines the quiet pattern that fails; check the lights you entered, because one wrong light is enough.
Worked example
Press Example for a 5 x 5 board with the middle 3 x 3 block lit. The shortest solution takes 13 presses. A single light in the very center needs 11, and a board with all 25 lights on needs 15.
We tested the solver by pressing every suggested light on a separate board model and checking that all lights went out, and by comparing it with a brute-force search over every possible set of presses on 3 x 3, 4 x 4 and 2 x 3 boards.
Lights Out was an electronic handheld game by Tiger Electronics; the name is used here only to say which puzzle this solves, and this site has no connection with its makers.
Tips for solving by hand
- Chase the lights: for each lit light in the top row, press the light directly below it. Repeat row by row. All lights end up in the bottom row.
- On 5 x 5, the pattern left in the bottom row tells you which top-row lights to press before chasing again; after the second chase the board is clear. The solver does this instantly for any pattern.
More one-player puzzles with a provably shortest answer: the 15 puzzle and the Tower of Hanoi.
Solver tested . Found a problem? Tell us.
Questions
Is every Lights Out puzzle solvable?
On a 5 x 5 board, no: only 1 in 4 arrangements can be switched off. Puzzles that come with the game are always solvable, so if the solver says unsolvable, check the lights you entered.
Does the order of presses matter?
No. Each light is switched once for every press that touches it, whatever the order. Pressing the same light twice cancels out, so every solution is a set of lights pressed once each.
What is the fewest number of presses?
It depends on the board. The solver checks every solution of your board and shows the one with the fewest presses. On 5 x 5, a board with all lights on needs 15.
Can it solve other sizes?
Yes: any board from 2 x 2 to 10 x 10, square or not. Pick the rows and columns above the board.
Does it work for the version where diagonals switch too?
Not yet. This solver uses the standard rule: a press switches the light and its up, down, left and right neighbors.