GenerateRandomSearch

Country Road Puzzle Generator

A single loop runs along this grid's own lines, splitting every square into inside it or outside it. Every numbered square has to end up inside. A number's value is how many inside squares it can see along its own row and its own column, counting itself, looking outward until the loop or the edge of the grid blocks the view. There is no other rule about where the loop can go — no numbers appear on the outside squares at all, and the loop's own shape is worked out entirely from what the inside numbers can see.

What this generator does

Grows the outside region one square at a time from a shrinking pool, keeping a placement only while the inside squares stay connected, the outside squares still all reach the grid's own edge, and no two regions meet only at a single shared corner. Once a valid inside/outside split exists, every inside square is numbered with its true count, and those numbers are then thinned one at a time — keeping a removal only while the remaining numbers still pin the whole grid down to that one split and no other.

How to use this tool

  1. Choose a grid size, then print or copy it.
  2. Decide which squares are inside the loop and which are outside, so every numbered square is inside.
  3. Check each number against how many inside squares it can see along its own row and column, itself included.
  4. The inside squares must all connect to one another, and the outside squares must all connect to the grid's own edge — no enclosed pocket of outside squares anywhere.
  5. Show the answer to check the finished grid.

Understanding the controls

Grid
5, 6 or 7 squares a side. All three are measured to settle within a couple of seconds, worst case.
Seed (optional)
Type anything to rebuild the same puzzle 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 loop-drawing puzzle where the only clue type is a line-of-sight count, not a shape or a size
  • A printable page with a genuinely different win condition from this site's other enclosure puzzles — one boundary, not several regions
  • Practice reasoning about what a single connected shape can and cannot look like
  • Reprinting the identical grid later from its seed

How this generator works

A connected region is not automatically a valid loop's interior: a connected region can still have a hole (an outside pocket entirely walled in by inside squares, which would need its own separate inner boundary), or touch itself at a single shared corner (which pinches a loop's path through itself at that one point, so it stops being one simple, non-crossing curve). Both are checked as their own properties, on top of ordinary connectivity, using a virtual ring of "always outside" squares wrapped around the whole grid — an outside square counts as safe only once it can reach that ring through other outside squares, and a 2x2 block is rejected the moment it has inside squares on one diagonal and outside on the other. A first version of the solver checked both properties after every single square was decided, regardless of which way it went, and measured badly: 40 seeded attempts at 7 squares a side averaged nearly 3 seconds and peaked at 24.8 seconds. Since fixing a square outside can only threaten the inside squares' own connectivity, and fixing a square inside can only threaten an outside square's route to the ring, each property only needs checking on the one branch that could actually break it — the same one-directional argument this site's own Kurodoko generator already relies on for its own connectivity check. That roughly halved the cost, but the worst case was still 18.2 seconds, since the "no two outside squares may touch" rule that shrinks Kurodoko's own search tree has no equivalent here. The remaining fix bounds the thinning step itself to 500,000 search steps: thinning is safe to stop at any point, since a number is only ever removed once its absence is proved to still pin down one answer, so stopping early yields a puzzle with a few more numbers than strictly necessary rather than a wrong one. Measured with that budget in place, 40 seeded attempts peaked at 135 milliseconds at 5 squares a side, 1.5 seconds at 6, and 2.1 seconds at 7 — which is why the grid stops at 7, one size short of Kurodoko's own 8.

Randomness and fairness

Which squares are tried first while growing the outside region, and the order numbers are tested for removal while thinning, both come from your browser's cryptographic random source. Giving a seed replaces that source with a repeatable one, so the same puzzle 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 7 squares a side. Measured directly, an 8-square grid regularly took several seconds to settle even after two rounds of optimisation, which is too slow for a page a person is waiting on.
  • Difficulty is not graded — a grid can be settled from a handful of well-placed numbers or need several worked out together.
  • The outside region is grown towards a random target of 35 to 55 per cent of the grid, so loops vary in size but never fill or nearly empty the grid.

Privacy and your data

The loop is built, thinned and checked for a single answer entirely in your browser. Nothing you type as a seed, and no puzzle made from it, leaves the device.

Frequently asked questions

Why does this puzzle have no numbers on the outside squares?
Only squares inside the loop are ever numbered. The outside squares are worked out by elimination — from what the inside numbers can see, and from the rule that the outside can never wall in a pocket of its own.
What's actually different between this and this site's Kurodoko generator?
The number rule is identical — count what you can see along your own row and column. What differs is what is allowed to block that view: Kurodoko individually shades cells with no shape restriction beyond "no two shaded cells touch"; here, the outside has to be the exterior of one single, hole-free, non-self-touching loop, which is a stricter, genuinely different shape to reason about.