In Lights Out, pressing a tile flips it and the tiles directly above, below, left and right of it. The goal is every light off. Two facts make the puzzle solvable by a program: press order never matters, and pressing a tile twice does nothing. A solution is simply a set of tiles to press once each.
How this solver finds the shortest answer
Once the top row of presses is chosen, every press below it is forced. A tile left lit in one row can only be fixed from the row beneath, because anything above is already settled. So the solver only has to try each possible top row, at most 32 of them on a 5 × 5 board, and follow the consequences down.
A top row works if the bottom row ends dark. The solver collects every top row that works, counts the presses each one needs and shows you the smallest. That is a complete search, so the number it reports is a proven minimum.
That is also the most any solvable 5 × 5 board needs. We confirmed it by working outward from the empty board through all 8,388,608 reachable positions.
One shortest solution for the all-lit board. Press each marked tile once.
Which boards can be solved?
Boards that can be solved are exactly those a solved board can reach through legal presses. On 4 × 4 and 5 × 5 grids, that is only a fraction of all the ways to arrange the lights. We counted these figures with the same solver rather than taking them from a reference.
| Grid | Possible boards | Solvable | Press sets per solvable board | Hardest board |
|---|---|---|---|---|
| 3 × 3 | 512 | 512 (all of them) | 1 | 9 presses |
| 4 × 4 | 65,536 | 4,096 (1 in 16) | 16 | 7 presses |
| 5 × 5 | 33,554,432 | 8,388,608 (1 in 4) | 4 | 15 presses |
The extra press sets exist because some patterns change nothing at all. Press every tile in one of these “quiet patterns” and the board ends exactly as it began. Adding one to a solution gives another valid solution, which is why a solvable 5 × 5 board has four and a 4 × 4 board has 16. On 3 × 3, there are no quiet patterns, so each board has exactly one press set.
Solve it by hand with light chasing
Light chasing is the method people use without a computer. It will not always find the shortest route, but it does clear any solvable board.
- Chase down. Starting at the top, press the tile directly below every light that is on. Do this row by row until only the bottom row has lights left.
- Read the bottom row. On a 5 × 5 board, find its pattern in the table below. If it is not listed, the board cannot be solved.
- Press the top row. Press the columns shown in the table.
- Chase down again. Repeat the first step. This time the board clears.
| Bottom row still lit | Press in the top row |
|---|---|
We generated this table from the solver and tested every line by replaying the full method. Other published tables can differ, because a board can often be cleared from more than one top row.
Using the solver
Select the lit tiles to match your puzzle, then choose Solve this board. The tiles to press are numbered, and Next press applies them one at a time so that you can follow along. To check your entry, compare the board with your puzzle before you start: one wrong light can make a solvable board look impossible.
Every tile is a real button. Arrow keys move between tiles, and Enter or Space switches the focused tile. The result is announced as text and written out by row and column, so you do not have to read the board visually.
Lights Out solver questions
Does the order of presses matter?
No. Each press flips the same fixed set of tiles, so a set of presses always gives the same final board in any order. The solver numbers its presses in reading order only so that they are easy to follow.
Why does the solver say my board cannot be solved?
Only some boards can be cleared: every 3 × 3 board, one in 16 of the 4 × 4 boards and one in four of the 5 × 5 boards. A real puzzle will not start on an impossible board, so check for one mistyped light first.
Is the answer really the shortest?
Yes, for the rule used here. The solver tests every possible first row. The rows below are then forced, so no valid solution is missed, and it keeps the one with the fewest presses. Another solution may tie with it.
Does this work for my version of the game?
It works when a press flips the tile and its neighbours above, below, left and right, with no wrap-around at the edges, and when the goal is to turn every light off. Variants with more colours, wrapping edges or a different starting rule need a different solver.