Puzzle Solver

Light Out Solver

Build any 2×2 to 5×5 Lights Out board, toggle cells, and get the exact optimal move sequence using Gaussian elimination over GF(2).

Classic grid puzzle

Light Out Solver

Build any 2x2 to 5x5 Light Out puzzle, switch between linked play and manual edit mode, then solve it with the same optimal Gaussian-elimination logic from the original project.

Interactive board

Tap any bulb to toggle it and its neighbors together.

5 x 5

Build a puzzle or randomize one, then solve it.

Solution steps

Solve a board to see the guided move path.

What is Lights Out?

Lights Out is an electronic puzzle game that Tiger Electronics released in 1995. Avi Olti invented it. The concept is simple: a 5x5 grid of lights, some on and some off. Press one light and it toggles — along with its four neighbors (up, down, left, right). The goal is to turn every light off.

That single rule — press one light, toggle five — creates surprisingly deep puzzles. A move in the corner only affects three cells. A move in the center affects five. Every move ripples outward, and undoing a mistake isn't straightforward because the "undo" (pressing the same cell again) toggles the same five cells back, but also flips any cells you've fixed since.

The original handheld game sold over 10 million units. It spawned sequels, knockoffs, and decades of math papers analyzing why the puzzle always has a solution.

Why Every 5x5 Puzzle Has a Solution

Here's the mathematical fact: every possible 5x5 Lights Out board is solvable. Not most. All of them. This was proven using linear algebra over GF(2) — a number system where the only values are 0 and 1, and 1+1=0.

Each cell can be either on (1) or off (0). Each move is just addition modulo 2. The entire board state is a system of 25 linear equations with 25 unknowns. Because the coefficient matrix for the 5x5 case has full rank — all 25 rows are linearly independent — the system always has a unique solution.

This doesn't mean the solution is obvious. A random 5x5 board typically requires 8-15 moves, and finding them by hand is genuinely hard. But the solution is always there. The math guarantees it.

How Our Solver Finds the Shortest Path

The solver converts your board into a system of equations over GF(2) and applies Gaussian elimination. This is the same algorithm used in linear algebra courses, but with every operation done modulo 2.

The result is a set of cells that, when pressed in any order, will turn all lights off. The solver presents these as step-by-step mini-boards so you can follow along one move at a time. Each step shows the board before and after that press.

Because Gaussian elimination produces the minimal solution, the move count you see is optimal — no shorter solution exists for that board.

The Chase-the-Lights Method You Can Use by Hand

You don't need a solver if you know the chase-the-lights technique. It works like this:

  1. Look at the top row. Any light that's on, press the cell directly below it.
  2. Now the top row is all off. Look at the second row. Any light on, press below it.
  3. Repeat for each row, working top to bottom.
  4. By the time you reach the bottom row, the entire board above it is solved. If the bottom row happens to be all off, you're done.

The catch: this method doesn't guarantee the fewest moves. A chase-the-lights solution might take 20 presses when the optimal solution takes 8. For casual play it's fine. For the shortest path, use the solver.

Which Board Sizes Are Hardest?

2x2 is trivial — at most 4 cells, at most 4 moves. You can brute-force it in your head. 3x3 is solvable in a few seconds of trial and error.

4x4 starts to get interesting. There are 65,536 possible board states (2^16). The chase-the-lights method still works, but the solution paths get longer and harder to find manually.

5x5 is the sweet spot. 33 million possible states (2^25), solutions typically 8-15 moves, and the math is beautiful — it's the size where Gaussian elimination becomes genuinely necessary. This is the original game size and it's where this solver earns its keep.

Why Pressing Randomly Never Works

Here's a common scenario: you press a few cells, the board looks better, then worse, then you press some more and end up further from solved than when you started. What happened?

Every press toggles five cells (or three at edges, four at corners). That means each move changes almost 20% of the board. Two moves in the same row interact — the second move partially undoes the first. Three moves in a cluster create interference patterns that are nearly impossible to reason about mentally.

The solver avoids this entirely. It doesn't press cells one at a time and hope for the best. It computes the exact set of presses needed, all at once, using linear algebra. No guessing. No undoing.

Light Out Solver FAQs

How does this Light Out solver work?

The solver uses Gaussian elimination over GF(2) — modular arithmetic where 1+1=0 — to find the optimal move sequence. This is the same algorithm that proves every 5x5 board is solvable.

What is the difference between Linked Toggle and Edit Puzzle?

Linked Toggle behaves like the real game: clicking a light flips it plus its neighbors. Edit Puzzle lets you set up any custom board one light at a time without the neighbor effect.

Can I solve random puzzles and manual board setups?

Yes. Generate random boards, recreate a puzzle you already have, then solve it and review every step as a mini-board sequence.

Are all Lights Out boards solvable?

Every 5x5 Lights Out board is solvable — this is mathematically proven. Smaller boards (2x2, 3x3, 4x4) are also always solvable with the standard toggle pattern (self plus 4 neighbors).

What is the chase-the-lights method?

It is a manual technique where you solve the top row first, then use the second row to fix the first, the third row to fix the second, and so on. It works for most boards but does not guarantee the fewest moves.

Can I use the solver on my phone?

Yes. The board and step cards are fully responsive. Tap cells to toggle lights, then tap Solve to get the optimal path.

More Solvers