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.

How many such routes are there through a 20×20 grid?

def r(x, y):

if x == 0 and y == 0:
p = 0
elif x == 0 or y == 0:
p = 1
else:
p = r(x - 1, y) + r(x, y - 1)

return p


def r(x, y):
d = []
for i in range(y + 1):
t = [0] * (x + 1)
d.append(t)

for iy in range(y + 1):
for ix in range(x + 1):
if ix == 0 and iy == 0:
v = 0
elif ix == 0 or iy == 0:
v = 1
else:
v = d[iy - 1][ix] + d[iy][ix - 1]
d[iy][ix] = v

return d[y][x]