Lattice paths
Problem 15
Starting in the top left corner of a 2×2 grid, and only being able to move to the right and down, there are exactly 6 routes to the bottom right corner.
![](https://projecteuler.net/project/images/p015.gif)
How many such routes are there through a 20×20 grid?
这个只要从上到下,一个一个加就好了,非常简单。
def routes():
grid = [[0] * 21] * 21
for i in range(0,21):
grid[0][i] = 1
grid[i][0] = 1
for i in range(1,21):
for j in range(1,21):
grid[i][j] = grid[i][j-1] + grid[i-1][j]
return grid[20][20]
print(routes())