gizmobench

Lights Out Solver

Set the lights on a board of up to 10 by 10, choose which cells a press flips, and press Solve. The solver treats the board as a set of equations over two values, on and off, and solves them by Gaussian elimination, so it knows exactly which boards can be cleared. It shows the rank and nullspace size for the size and rule, lists the presses in reading order, and plays them back one at a time. When a board has more than one solution it checks every one, up to 1,048,576 of them, and calls the answer the shortest only then. When no presses can clear a board it says impossible and outlines the cells that prove it, instead of giving a sequence that does not work.

boardexample, 5 x 5, plus rule

13 lights on: B1 E1 B2 C2 D2 E2 A3 D3 E3 B4 D4 E4 B5

a press flips the cell and its 4 neighbours

solutionnot solved yet

Press Solve to work out which cells to press.

Rank 23 of 25, nullspace 2: 1 in 4 boards of this size and rule can be cleared.

Size
Rule
Edges
A tap
Lights on
13
Presses
not solved yet
Rank
23 of 25, nullspace 2
Solutions checked
none
  • The board above5 x 5, plus rule
    not solved yet
  • All lights on5 x 5, plus rule
    15 presses, the shortest of 4 solutions
  • Only A1 on5 x 5, plus rule
    impossible: no set of presses clears it, so no sequence is given
  • All lights off5 x 5, plus rule
    0 presses: every light is already off
Board as text

One row per line: # or 1 for a light that is on, . or 0 for one that is off. Spaces and commas between cells are ignored. Up to 10 rows of up to 10 cells.

Common questions

How does a Lights Out solver work?
A press always flips the same cells, and flipping a cell twice puts it back, so the order of presses does not matter and pressing a cell twice is the same as not pressing it. A solution is therefore a set of cells to press once each. That makes the board a system of equations over two values, and Gaussian elimination either finds a set of presses that clears it or shows that none exists.
Can every Lights Out puzzle be solved?
No. On the classic 5 x 5 board, where a press flips the cell and its 4 neighbours, the rank is 23 of 25, so only 1 in 4 of the possible boards can be cleared. A board with only the corner A1 lit is one that cannot: load it from the worked cases and press Solve, and the solver outlines the cells that prove it. On classic boards of 6, 7, 8 and 10 cells a side every board can be cleared.
What is the fewest number of moves to solve 5x5 Lights Out with every light on?
15 presses. Every 5 x 5 board that can be cleared has exactly 4 solutions under the classic rule, and the solver checks all 4 before it calls one the shortest. Load All lights on from the worked cases and press Solve to see the 15 presses and play them back.
Does the order of the presses matter?
No. Each press flips the same cells whatever the board looks like, so any order ends on the same board. The solver lists the presses in reading order, row by row from A1, and never presses a cell twice.
What do rank and nullspace mean here?
The rank counts the presses that act independently: of the 2 to the power n boards on n cells, 2 to the power rank can be cleared. The nullspace holds the quiet patterns, press sets that change nothing at all, and the number shown is its dimension. A board that can be cleared has 2 to the power of that number solutions, which is why the classic 5 x 5 board, with a nullspace of 2, has 4 solutions for every clearable board.
Why would an answer not be the shortest?
The solver proves an answer shortest by checking every solution, and it does that while there are at most 1,048,576 of them. Of the 800 combinations of size, rule and edge setting it offers, three have more: 6 x 9, 9 x 6 and 9 x 9 with the square rule and wrapping edges. There it checks 1,048,576 solutions, then tries improving the best one a quiet pattern at a time, and labels the result not proven shortest. The presses still clear the board.
Which Lights Out variants does it handle?
Boards from 1 x 1 to 10 x 10, with four press rules: plus (the cell and its 4 neighbours), neighbours only (the 4 neighbours but not the cell), X (the cell and its 4 diagonal neighbours) and square (the cell and all 8 around it). Presses can stop at the edge or wrap to the far side. When wrapping, a cell is never its own neighbour, and a cell reached twice is flipped once.
Can I play the board myself, or use it on a phone?
Yes. Set A tap to Presses and each tap presses the cell as the game does. The arrow keys move around the board and Space or Enter acts on the selected cell, and the row and column picker under the board has a full-size button for small screens. The board, rule, edge setting and tap mode are kept in this browser for your next visit, and the board is not sent anywhere.

Every press list is replayed on your board before it is shown, and a board that no presses can clear is reported as impossible, with the cells that prove it, never given a made-up sequence. A solution is called the shortest only when every solution was checked, up to 1,048,576 of them; past that limit it still clears the board but may not be the shortest, and the page says so.