GenerateRandomSearch

Numberlink Puzzle Generator

A Numberlink grid prints several numbers, each appearing exactly twice. The puzzle is to draw one path per number, moving only up, down, left and right, connecting its two printed squares — and the rule that makes this more than a maze is that the paths, between them, must cover every square of the grid. No path may cross itself or any other path, and there is no square left over once the grid is solved: work out how the paths thread through the empty squares and the whole grid fills in at once. Every grid here is checked to have one answer and no other.

What this generator does

Builds one path that visits every square of the grid exactly once, cuts it at random into as many pieces as there are pairs, and prints each piece's two ends as a matching numbered pair — which by construction guarantees the finished grid's own answer already covers every square. A separate exhaustive search then proves, from the printed numbers alone and with no knowledge of how the grid was built, that they pin down exactly one way to fill it; a grid that fails this check is discarded and rebuilt from scratch.

How to use this tool

  1. Choose a grid size and how many numbered pairs you would like.
  2. Print or copy the grid; each number appears on exactly two squares.
  3. Draw a path between each pair, moving only up, down, left and right.
  4. Make sure no path crosses itself or another path, and that every square ends up on exactly one path.
  5. Show the answer to check the finished grid.

Understanding the controls

Grid and pairs
5x5 or 6x6, each offered with a range of pair counts. Fewer pairs means longer, more entangled paths and is the harder end; more pairs means shorter paths and is the easier end.
Seed (optional)
Type anything to rebuild the same grid later, which is how you reprint a page you have lost. The seed makes the puzzle repeatable; it carries no cryptographic strength and is not a secret.

Common use cases

  • A path-drawing puzzle for a puzzle page, classroom starter or newsletter
  • A change of pace from this site's shading and loop puzzles
  • A printable page for a puzzle club or logic-puzzle collection
  • An easier, more-colours grid for a quick solve, or a harder, fewer-colours grid for a slow one
  • Reprinting the identical grid later from its seed

How this generator works

Cutting one grid-spanning path into pieces guarantees the answer it was built from covers every square, but it proves nothing about whether some other set of non-crossing, full-covering paths could also satisfy the same two printed numbers per pair — and unlike this site's shading puzzles, there is no numeric clue to adjust if it turns out there is more than one. Measured directly: a single construction attempt comes out uniquely solvable only 10 to 40 percent of the time depending on grid size and pair count, so rather than repairing a bad grid the generator discards it and builds an entirely fresh path and cut. The uniqueness check itself is an exhaustive search that always extends whichever path currently has the fewest legal next squares, and prunes the moment either some empty square becomes reachable by nothing, or some still-open path can no longer reach its own target — over 420 generated grids across every offered size and pair count, that retry loop found a uniquely-solvable grid every single time, and every stored answer passed its own separate structural check (that each path is simple, no two paths share a square, and the grid is fully covered), worst case under a second.

Randomness and fairness

The grid-spanning path, where it gets cut into pairs, and which pair gets which number all come from your browser's cryptographic random source. Giving a seed replaces that source with a repeatable one, so the same grid can be printed again; the seed is for reproducibility, not cryptographic strength.

For how randomness is produced across the whole site, see how Generate Random works.

Limitations and good to know

  • The grid stops at 6 squares a side — a measured limit: finding a random Hamiltonian path (the construction step, not the uniqueness check) on a 7-square grid was found to sometimes take well over a minute.
  • Difficulty is not graded beyond the pair count. A grid with few, long paths can still open up quickly from an easy corner, and a grid with many, short paths can still have one fiddly crossing.
  • Paths are only ever simple chains between two endpoints — there is no variant here where a number appears more than twice, which some competitor implementations allow.
  • The two endpoints of a very short pair can end up directly adjacent, which is a valid but visually trivial path.

Privacy and your data

The grid, its paths and the check that the answer is unique are all done entirely in your browser. Nothing you type as a seed, and no puzzle made from it, leaves the device.