Counting Shortest Monotone Grid Paths

A path taking only right and down steps is determined by the positions of one kind of step in its ordered move list.

Source
Anbloq
Language
English
Created
Updated
Chapters
4
Reading time
1 min
In this article4 chapters
  1. Count the positions
  2. Handle obstacles explicitly
  3. Choose which moves carry the vertical steps
  4. Subtract paths through a blocked point when they split cleanly

Count the positions

To travel three units right and two units down requires five moves. Choosing the two down positions yields \(\binom52=10\) paths. Unordered combinations count those positions, although each resulting move sequence is ordered.

Handle obstacles explicitly

A blocked cell can eliminate several paths. At each allowed cell, count paths from its two allowed predecessors. A blocked cell contributes zero. Bottom-up recurrence evaluation gives a suitable traversal order.[1]

Choose which moves carry the vertical steps

To travel from \((0,0)\) to \((3,2)\) using one-step east and north moves, every route contains three east and two north moves. Choose the two positions for north among five, giving ten routes without obstacles. See unordered combinations.

Example N E E N E visits (0,1),(1,1),(2,1),(2,2),(3,2)
North positions: 0 and 3
Count: choose(5,2)=10

Subtract paths through a blocked point when they split cleanly

If \((1,1)\) is blocked, a route through it has two ways to reach it and three ways to finish from it. That eliminates six paths, leaving four. With multiple blocked points, a route can visit more than one and require overlap correction.

References

  1. Eric Lehman, F. Thomson Leighton and Albert R. Meyer, Mathematics for Computer Science ↩