How to play
The board is a square grid of 4x4, 5x5 or 6x6 lights. A yellow cell is a light that is on and a dark cell is off. Pressing a cell flips that cell and the cells that touch it on the left, right, top and bottom. Diagonal neighbours are not affected, and at the edge of the board the missing neighbours are simply skipped, so a corner press changes 3 lights, an edge press changes 4 and an inner press changes 5. Every new puzzle starts from a random pattern of lit cells. When the last light goes out the board locks and you see how many clicks you used next to the smallest number that was possible for that starting pattern.
- Clicks counts every press since the puzzle began. Pressing the same cell twice puts everything back, so a second press on the same cell is always wasted effort.
- Lights on is the current number of lit cells. A lower number does not always mean you are closer to the answer (see the misconceptions below).
- Hint outlines one cell of a shortest solution for the board as it is right now. Each hint is counted, so save them if you want a clean run.
- Retry this puzzle restores the exact starting pattern. New puzzle deals a fresh one, and the game avoids repeating the layout it just gave you. Changing the difficulty also deals a new puzzle.
The mathematics behind it
Each light has only two states, so a press is a flip, and flipping twice cancels out. That has two consequences. First, the order of your presses never matters. Second, in any solution each cell is pressed either zero times or once; pressing it three times is the same as pressing it once. A complete solution is therefore just a choice of which cells to press, and a 5x5 board has 225 such choices. Writing the board as a vector of 0s and 1s, the effect of all presses together is a matrix product in which addition is done mod 2 (XOR). Solving the puzzle means solving the linear system Mx = b over the two-element field, where b is the starting pattern, x is the set of cells to press and M records which lights each press touches. Gaussian elimination solves it, and that is exactly what the hint and the minimum-click display on this page do each time the board changes.
How many solutions a board has depends on the matrix M. A quiet pattern is a non-empty set of cells that you can press without changing the board at all. If quiet patterns exist, the system has several solutions for a solvable start and no solution at all for the other starts. The table below is computed when the page is built, straight from the rules above.
| Grid | Cells | All light patterns | Quiet-pattern dimension | Solvable patterns | Share solvable | Solutions per solvable pattern |
|---|---|---|---|---|---|---|
| 4Γ4 | 16 | 65,536 | 4 | 4,096 | 1/16 | 16 |
| 5Γ5 | 25 | 33,554,432 | 2 | 8,388,608 | 1/4 | 4 |
| 6Γ6 | 36 | 68,719,476,736 | 0 | 68,719,476,736 | 100% | 1 |
The largest grid is the tidiest. On 6x6 there are no quiet patterns, so every one of the 236 starting patterns can be cleared and each has exactly one solution. The small 4x4 grid is the opposite: it has the fewest cells, yet its quiet patterns form a four-dimensional space, so only one pattern in sixteen is solvable and each solvable pattern can be cleared in sixteen different ways. The 5x5 board sits in between, with a quarter of all patterns solvable and four solutions each. The three non-empty quiet patterns of the 5x5 board are drawn below. Pressing every filled cell of one of them leaves the board exactly as it was, which is why one solution always comes with three siblings.
β‘ β β β β‘ β β‘ β β‘ β β β β‘ β β β β‘ β β‘ β β‘ β β β β‘ (16 cells pressed)
β β‘ β β‘ β β β‘ β β‘ β β‘ β‘ β‘ β‘ β‘ β β‘ β β‘ β β β‘ β β‘ β (12 cells pressed)
β β β‘ β β β‘ β‘ β‘ β‘ β‘ β β β‘ β β β‘ β‘ β‘ β‘ β‘ β β β‘ β β (12 cells pressed)
The puzzles you receive here are always solvable. The generator starts from a dark board and applies a random selection of presses (about half of 25 tries on 5x5, for instance), so reversing those presses clears the board. If the random selection happens to return a fully dark board, the centre cell is pressed once so you never start on a finished puzzle. The randomness comes from the browser’s Math.random, which is fine for a game but not meant for security.
How many lights each press changes
Where you press decides how much of the board moves. Corners change 3 lights, edge cells 4 and inner cells 5. This is the reason experienced players like to work from the edge inwards: edge moves are easier to predict and undo than a press in the middle.
| Grid | Corner cells (3 lights change) | Edge cells (4 change) | Inner cells (5 change) |
|---|---|---|---|
| 4Γ4 | 4 | 8 | 4 |
| 5Γ5 | 4 | 12 | 9 |
| 6Γ6 | 4 | 16 | 16 |
Solving by hand: chasing the lights
You do not need linear algebra to solve the puzzle. The classic method is called chasing the lights. Work down the board one row at a time: for every lit cell in the top row, press the cell directly below it. That turns the top row dark without touching it again. Repeat the same step for the second row, then the third, and so on until only the bottom row can still contain lit cells. If the bottom row is dark, you have won. If not, undo the work, change which cells of the top row you press first, and chase again. The top row alone determines everything below it, so the number of top-row choices (2 to the power of the board width) is the number of attempts you might need. Checking random solvable boards confirms the counts: on 6x6 exactly one of the 64 top-row choices clears the board, on 5x5 four of 32 do, and on 4x4 all 16 do. That is a different face of the same table above. The hint button gives you the same answer without the trial and error.
Worked examples
Example 1: two presses, eight lights. On an empty 5x5 board press the top-left corner and then the exact centre. The corner flips 3 lights, the centre flips 5, and the two groups do not overlap, so 8 lights are on. Repeating the same two presses clears them. No single press can switch off 8 lights because one press changes at most 5, so the minimum is exactly 2 clicks. Eight lit cells, two clicks: the number of lit cells is a poor predictor of the work needed.
Example 2: the board with every light on. Solving the all-on board with the same elimination code used by the page gives a minimum of 4 clicks on 4x4, 15 on 5x5 and 28 on 6x6. Applying each of those solutions to the board really does turn everything off. Going from 16 cells to 25 cells nearly quadruples the work, from 4 to 15 clicks, so board size and difficulty do not grow in step.
Example 3: the hardest boards. Because every solvable 4x4 and 5x5 pattern can be listed, the worst case is known exactly. Of the 4,096 solvable 4x4 patterns, the most demanding one still needs only 7 clicks. Of the 8,388,608 solvable 5x5 patterns, the most demanding one needs 15 clicks, which is the same as the all-on board. For 6x6 the list is too long for this check, so no maximum is claimed here. Puzzles created by this page come from a random sprinkle of presses, so most need far fewer clicks than these worst cases.
Common mistakes and misconceptions
- “Fewer lights on means I am closer.” Not necessarily. A press that darkens three lights may leave a layout that needs more presses afterwards, and an optimal path can pass through boards with more lights on.
- Pressing a cell more than once. Two presses cancel, and order does not matter, so a shortest solution never uses a cell twice. If you pressed the same cell twice, those clicks bought you nothing.
- Starting in the middle. Inner presses change five lights and are hard to track in your head. Work row by row from the top instead.
- Thinking diagonals are affected. Only the four orthogonal neighbours change.
- Assuming 4x4 is the easy one. It has the fewest cells, but only one start pattern in sixteen is solvable in theory and each of those has sixteen solutions, so a single memorised trick can mislead you. This game only deals solvable boards, but the strategy that works on 6x6 does not transfer neatly.
Limits of this tool
The hint and the minimum are computed for the board as it stands: the page finds all solutions, keeps the one with the fewest presses and shows one of its cells. Several different solutions can share the same number of presses, so the highlighted cell is one correct choice, not the only one. Nothing is saved: when you reload the page the click and hint counters reset, and no scores or rankings are kept. It is a personal challenge, not a timed competition.
Getting more out of it
A good progression is to start on 4x4 with Retry this puzzle and repeat the same layout until you see which presses clear which corner. Move to 5x5 and practise chasing the lights without hints, and then play 6x6, where the solution is unique, and see whether you can finish near the displayed minimum. The gap between your click count and the minimum shown at the end is a simple score to try to shrink.
Frequently Asked Questions
Can every puzzle be solved?
Yes. Each puzzle is built by pressing random cells on a dark board, so pressing those same cells again clears it. The game never deals an unsolvable layout, even though most random light patterns on 4x4 and 5x5 boards are in fact unsolvable.
How is the hint chosen?
The page solves the current board with Gaussian elimination over mod-2 arithmetic. If there are several solutions it takes the one with the fewest presses and outlines one of its cells. Following the hints leads to that solution, although another solution with the same number of presses may also exist.
Is the 6x6 board harder than the 5x5?
It takes more bookkeeping by hand, but structurally it is the cleanest board: every start pattern has exactly one solution. How hard it feels depends on the method you use.
Can I finish in fewer clicks than the displayed minimum?
No. The minimum is the smallest number of presses that can switch off every light from your starting pattern, so your own count can equal it but never beat it.
Does it work with a keyboard or a touch screen?
Both work. With the keyboard, move between cells with Tab and press Enter or Space; focus stays on the cell you just pressed. Touch screens can tap cells directly.