def path_counter(x,y):
path = {}
#generate path[list] for matrix x*y
path[x,y] = 0
# matrix 0
if(x==1 and y==1):
return 0
# matrix 1
if(x==1 or y==1):
return 1
# path of the horizontal and vertical border
for coor_x in range(x-1,0,-1):
path[coor_x,y] = 1
for coor_y in range(y-1,0,-1):
path[x,coor_y] = 1
# loop to fill path of all other note
for coor_x in range(x-1,0,-1):
for coor_y in range(y-1,0,-1):
path[coor_x,coor_y] = path[coor_x+1,coor_y] + path[coor_x,coor_y+1]
return path
path = path_counter(21,21)
print(path[1,1])