Numberlink Puzzle & Generator Maths
Join each pair of numbers with a path that covers every cell — and see why the obvious way to generate these puzzles fails, measured rather than asserted.
Press a numbered cell and drag to draw its path; release to stop. Drawing from a number again starts that path over. Every cell must end up covered.
The obvious way to generate these puzzles does not work
The tempting approach is to drop pairs of numbers on random cells, run a solver, and keep the boards that work. Before building it that way we measured how often it would succeed — 400 random placements per row, asking each time whether the paths can be routed so that every cell is covered:
| Pairs on a 6 × 6 | Random placements that work |
|---|---|
| 3 | 15.25% |
| 4 | 5.25% |
| 5 | 1.50% |
| 6 | 0.50% |
| 8 | none in 400 |
A real puzzle wants five to eight pairs. At five that is one board in 67, and at eight it did not happen once. Each failed attempt costs a full search, so scatter-and-test is not merely slow — it is hopeless at the sizes anyone would want to play.
So this tool generates the other way round. It traces a random path that visits every cell on the board exactly once, cuts it into segments, and keeps only each segment's two ends as a numbered pair. Coverage is then guaranteed by construction, and every board is solvable because it was built from a real solution rather than tested into one.
The control is what makes those numbers mean anything
A result of "zero out of 400" could just as easily mean the solver is broken or its step budget is too small. So the same solver, at the same 80,000-step budget, is run against boards the generator built — boards that have a solution by construction and must therefore all come back solvable:
| Board | Known-good boards recovered |
|---|---|
| 5 × 5 | 60 of 60 |
| 6 × 6 | 60 of 60 |
| 7 × 7 | 6 of 32 — the budget bites here |
At 5 × 5 and 6 × 6 it recovers every single one, so the random figures at those sizes are about the boards and not about the search. At 7 × 7 it does not — which does not mean 7 × 7 is unsolvable, it means the cap is what is being measured there. Those numbers are therefore left out of the table above rather than reported as though they were clean. You can still play a 7 × 7; it is only the statistics at that size that the control refuses to license.
Two bugs the control caught, one of which looked like a discovery
The first version of the solver reported 0% at every size, including 5 × 5. That is a striking headline and it was entirely wrong. The solver forbade a path from running alongside itself — which sounds like tidiness, but it also stopped a path approaching its own target from a neighbouring cell, and made even a 2 × 2 board unsolvable. A solver that cannot solve a board built from a known answer is broken, whatever it reports about anything else. That is precisely what the control exists to catch.
The second was in generation, and it has a tidy explanation. Colour the grid like a chessboard: every step of a path moves to the opposite colour, so a route through all of an odd number of cells must start and finish on the majority colour. A 5 × 5 has 13 squares of one colour and 12 of the other, so starting anywhere on the minority colour is impossible rather than merely unlucky — and picking the start at random meant every 5 × 5 failed outright. Choosing the start by parity fixed it, and both sizes now generate every time.
How to use
- Pick a board size and press New puzzle.
- Press on a numbered cell and drag to draw its path.
- Join each number to its matching partner without crossing another path.
- Every cell must end up covered — a correct-looking board with a gap is not finished.
- Use Clear path or Reveal answer if you get stuck.
Frequently asked questions
What are the rules of Numberlink?
Each numbered cell has exactly one partner somewhere on the board. Draw a path between every pair so that no two paths cross or share a cell, and so that together they cover every single square. The full-coverage requirement is what separates this from simply connecting dots, and it is the rule that makes the puzzle hard.
Why not generate puzzles by scattering numbers randomly?
Because it almost never works, and we measured how badly. Dropping pairs at random on a six by six board and asking whether a full-coverage solution exists: three pairs succeed 15% of the time, five pairs 1.5%, and eight pairs zero times in four hundred attempts. A real puzzle wants five to eight pairs, so that approach needs dozens of tries at best and never succeeds at worst.
How are the puzzles here generated?
Backwards, from a solution. A random path is traced that visits every cell on the board exactly once, then cut into segments, and only each segment two ends are kept as the numbered pair. Full coverage is guaranteed by construction rather than hoped for, and every board is solvable because it was built from a real answer.
Why does the success rate collapse so fast with more pairs?
Full coverage is a far harsher demand than connection. Almost any two endpoints can be joined somehow on an open board; what fails is joining all of them and leaving no cell behind. Each extra pair adds two fixed cells the other paths must route around while removing the freedom that made the previous pair easy, and the rate falls by roughly a factor of three per pair added.
Can a path run alongside itself?
Yes. Paths may not cross or share cells, but a path is allowed to run next to itself, which is what makes covering every square possible at all. An early version of our solver forbade this and could then never approach its own target from a neighbouring cell, which made even a two by two board unsolvable.
Is every puzzle here guaranteed solvable?
Yes, because each one is carved out of a complete solution rather than generated and tested. The same solver is also run against those generated boards as a control, and it recovers every one of them at the sizes offered here, which is what makes the measurements on this page mean anything.
Why is there a limit on board size?
The search cost grows quickly. At seven by seven our solver recovers only a fraction of known-good boards within its step budget, so rather than quote figures that would be measuring the timeout instead of the puzzle, the analysis on this page is restricted to the sizes where the control passes cleanly.
Does this send anything anywhere?
No. Puzzles are generated, drawn and checked entirely in your browser, and nothing is uploaded.
🔒 This tool runs entirely in your browser. Nothing you enter is uploaded, logged, or stored.