Files
2025-12-26 17:35:14 +08:00

22 lines
417 B
Python

"""
Starting in the top left corner of a 2 X 2 grid,
and only being able to move to the right and down,
there are exactly 6 routes to the bottom right corner.
How many such routes are there through a 20 X 20 grid?
"""
import math
def grid_paths(m: int, n: int) -> int:
return math.comb(m + n, m)
def main() -> None:
print(grid_paths(20, 20))
if __name__ == "__main__":
main()