Lattice paths count
Your task
On a grid with (rows+1) by (cols+1) intersection points, you start at the top-left corner and may step only right or down by one unit at a time until you reach the bottom-right corner. Return the number of distinct monotonic lattice paths, modulo mod. For example, a 2-by-2 grid of moves (2 rights, 2 downs) has 6 paths. Assume 0 <= rows, cols <= 30 and mod >= 2.
Examples
lattice_paths_mod(rows: int, cols: int, mod: int) -> intExample 1
Input
lattice_paths_mod(2, 2, 1000000007)Output
6