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.
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
Press B2 E2 A3 D4 A5 B5 C5, in any order.
Shortest: all 4 solutions checked: 7, 13, 13, 15 presses.
Rank 23 of 25, nullspace 2: 1 in 4 boards of this size and rule can be cleared.
Before any press: 13 lights on.
- Size
- Rule
- Edges
- A tap
- Lights on
- 13
- Presses
- 7, shortest
- Rank
- 23 of 25, nullspace 2
- Solutions checked
- 4 of 4
- every light off after 7 presses, replayed on the board
- 15 presses, the shortest of 4 solutions
- impossible: no set of presses clears it, so no sequence is given
- 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 neighbors, 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 neighbors), neighbors only (the 4 neighbors but not the cell), X (the cell and its 4 diagonal neighbors) 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 neighbor, and a cell reached twice is flipped once.
- How do I solve a 3x3, 4x4 or larger Lights Out grid?
- Use Rows and Columns to choose the board size, then Clear board and switch on the lights that match your puzzle. Sizes from 1 to 10 are independent, so 3x3, 4x4, 5x5, 6x6 and 7x7 squares all use the same solver. For a rectangle with 7 rows and 5 columns, choose Rows 7 and Columns 5. Select the press rule and edge setting that match your puzzle, then press Solve. Changing the size keeps the cells that still fit, so clear the board first when entering a different puzzle.
- Can I paste a Lights Out board instead of clicking every cell?
- Yes. Open Board as text, paste one row per line into Paste a board, and choose Load this board. Use # or 1 for a light that is on and . or 0 for a light that is off; spaces and commas between cells are ignored. The rows must have equal lengths, with at most 10 rows and 10 cells per row. Loading text sets the board size and lights but keeps your current press rule and edge setting, so check those before pressing Solve.
- How can I copy the current board if clipboard access is blocked?
- Open Board as text and select the text in Current board, then use your browser's copy command. This readonly field follows the lights on the grid, including a board restored from this browser. Paste a board is a separate editable draft, so copying or changing the current board does not replace what you typed there.
- Why did Scramble leave every light off?
- Scramble applies random sets of presses and retries up to 24 times when the result is all off. Empty or cancelling press sets can still leave every light off after those attempts. That result does not prove that no press can change the board. Press Scramble again or switch on lights to enter a puzzle.
- 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.