Gridwalk

The method

Build a route count one cell at a time

Gridwalk counts paths through cells, from the upper-left cell to the lower-right cell. A move goes exactly one cell right or one cell down; it cannot cross a blocked cell.

Cells are not moves

Rows are numbered from 1 at the top and columns from 1 on the left. In an R-row, C-column grid, any valid complete route makes exactly R + C − 2 moves and visits R + C − 1 cells. That step count describes a route if one exists; it does not prove a route is available. A single open cell has one empty route with zero moves. A blocked start or destination gives zero routes.

The counts-to-cell rule

A blocked cell has count 0. The open start has count 1. At any other open cell, the only possible last move is from above or from the left, so add those two predecessor counts. A missing neighbour outside the grid contributes 0. Following this rule in row order reuses already-computed counts instead of enumerating every possible path.

Open 3 × 3 grid:
1  1  1
1  2  3
1  3  6

For example, the bottom-right 6 is 3 from above plus 3 from the left. Place a block in the centre and that cell becomes 0; counts beyond it change, and the final total becomes 2. The displayed table always shows the exact count from the start to each cell, including zero at blocked or unreachable cells.

Exact totals, including large ones

Gridwalk uses integer arithmetic without rounding or a modulo operation. For a completely open grid, the count also equals binomial(R + C − 2, R − 1): choose which of the fixed moves go down. This is a useful independent check. Obstacles require the cell-by-cell method rather than that open-grid formula.

How the example route is chosen

The tool also works backwards from the destination to count ways to finish from each cell. If a complete route exists, start at the upper-left and choose right whenever that neighbour has a positive finishing count; otherwise choose down. This produces one deterministic right-first route. The SVG line, R/D trace and row,column cell list all describe that same route. The choice is not random, and the page does not list every route.

White cells are open, dark cells are blocked and the orange line marks the example route. The legend and textual route provide the same information without relying on colour. With one open cell the route is a point, and its text explicitly says zero moves. With no route, there is no example line or cell list.

Input grammar and bounds

Local current-only notes

Text and JSON include the grid, exact total, complete counts-to-cell table and the chosen example route. JSON uses decimal strings for every route count so another reader does not lose integer precision. Editing clears the current diagram, results, exports and manual-copy fallback. A clipboard request already sent to the browser cannot be recalled, but late responses cannot restore stale notes or mark them as current.

Model and primary references

The CSES Grid Paths I problem describes right/down paths avoiding obstacles. That programming problem asks for a modulo result; Gridwalk's smaller bounded grid returns the full exact count. The MIT 6.046J dynamic programming recitation transcript explains summing predecessor counts and reusing grid subproblems. Its vertical direction is reflected here to use down rather than up. These are mathematical references, not runtime services.

No diagonal or backward moves, costs, maps, random sampling or real-world navigation are part of this model.

Count your grid routes