Gridwise guides

Numbered path puzzles: how to find the route

In a numbered path puzzle you draw one continuous line through every cell of a grid. The line starts at the number 1 and visits the other numbers in order, and it cannot cross a wall or itself. Gridwise calls its version Path. It is a close cousin of the daily puzzles you may have seen on professional networking sites, and the same ideas apply.

The trouble is that the line is long and the early mistakes are quiet. You can draw a confident route for ten cells and only discover at the end that a corner was stranded. The six techniques below help you spot those problems before you draw, by reasoning about what the line must do rather than where it feels like going. In the examples, r2c3 means row 2, column 3, counted from the top-left.

1. Corners and walls force the line

Count the open neighbours of each cell. A corner cell has only two neighbours, and a cell in a walled-off nook may have the same. The line enters a cell through one neighbour and leaves through another, so a cell with exactly two open neighbours must use both of them, unless it is the start or the end of the line.

Example: r1c1 is a corner with neighbours r1c2 and r2c1. If r1c1 is not the start or the end, the line must run r1c2, r1c1, r2c1. Draw those two segments straight away. Each forced segment then removes options elsewhere: r1c2 now has one connection used, so it has only one more to give.

2. Spot the dead ends

The line has one start and one end. Any other cell needs two connections. So if a cell has only one open neighbour, it can only be the line's start or its end. The start is the number 1, so a one-neighbour cell with another number in it, or with no number at all, has to be where the line finishes.

A valid grid has at most two such cells, the start and the end. Once you find a one-neighbour cell that is not the 1, you know where the whole route finishes, and you can work backwards from it as well as forwards from the 1. If you find a third one-neighbour cell, an earlier move has gone wrong.

3. Check the distance between numbers

From one number to the next, the line moves one cell at a time, up, down, left or right. So the number of steps between two numbers is at least the distance between them, counting rows and columns. If 2 is at r1c1 and 3 is at r1c4, the line needs at least three steps, which means it passes through two cells in between.

In a tight grid that is often exactly right: if the shortest route is the only one that fits the cell budget, it is the route. When a wall blocks the straight line, the shortest legal path may be longer, and you can sometimes see that only one way around is possible. Measure each stretch before you draw it.

4. Use parity

Colour the grid like a chessboard. Every step goes from one colour to the other, so the number of steps between two numbers must be odd if the cells are on different colours and even if they are on the same colour. Another way to say it: the step count always has the same odd or even nature as the distance in rows plus columns.

Example: 2 is at r1c1 and 3 is at r1c4. The distance is three, which is odd, so the stretch from 2 to 3 takes three steps, or five, or seven, and never four. That is useful when a detour is tempting. A route that would use four steps is impossible, so you know to look for a shorter or a longer one. Parity quietly rules out a large share of wrong-looking routes.

5. Budget the empty cells

Every cell must be visited, so the cells with no number have to be absorbed into the stretches between consecutive numbers. Count the empty cells, then ask which stretches could possibly reach them. A large empty area next to only one stretch means that stretch has to be long, however close its two numbers are.

Conversely, if a stretch lies in a crowded part of the grid, it has no room to wander and the shortest legal route is probably the one. Estimating this budget helps you decide which stretch to extend and which to keep tight, and it combines well with parity, since a long stretch must still have the right odd or even length.

6. Never strand a region

Imagine the line has been drawn partway. The cells it has not yet visited must still form a single area that the line can reach and cover in one pass. If your next move would cut the remaining cells into two separate pieces, the line can only finish one of them, so the move is wrong.

Check this when the line runs along a wall or a long edge. Hugging an edge is tempting, yet it can seal off a pocket on the far side of the line. A strip of cells that becomes disconnected, or a single cell left with no free neighbour, is a signal to rub out the last stretch and try the other way around. Also keep an eye on cells that a later number must reach: if the line has boxed that number in, there is no way in.

Working it as a routine

Start with everything forced: corners, nooks and dead ends. Measure the distance between each pair of consecutive numbers and apply parity to rule out step counts. Then budget the empty cells to see which stretches must be long. Draw stretches in lightly, and before committing to each, run the stranded-region check. Bigger grids repeat the same reasoning on more numbers, which is why one clean habit beats cleverness.