✨ feat(eular_13.py):新增超大整数加法解决方案 📝 docs(eular_13.md):添加算法说明文档 ✨ feat(eular_14.py):新增Collatz序列最长链计算 📝 docs(eular_14.md):添加性能优化说明 ✨ feat(eular_15.py):新增网格路径组合数学解法 📝 docs(eular_15.md):添加组合数学详细说明 ✨ feat(eular_16.py):新增幂数字和计算功能 ✨ feat(eular_16.hs):新增Haskell版本实现
22 lines
417 B
Python
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()
|