Paths through a grid
Write grid_paths(rows, cols) that returns how many routes go from the
top-left cell to the bottom-right cell of a rows × cols grid, moving
only right or down. Both dimensions are at least 1.
grid_paths(1, 1) -> 1
grid_paths(2, 2) -> 2
grid_paths(3, 3) -> 6
grid_paths(3, 7) -> 28
The point is to practise a two-dimensional table. Grids up to 18 × 18
are checked, where trying every path would take far too long.
def grid_paths(rows, cols):
...