blob: 749be0405a2f55a087a83804e20acf5bf772b90c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
size = 20
field = [ [ 1 for i in range(0, size+1) ] for i in range(0, size+1) ]
for i in xrange(1, size+1):
for j in xrange(1, size+1):
field[i][j] = field[i][j-1] + field[i-1][j]
print field[size][size]
#
# recursive solution. too slow
#
#def count_path(width, height):
# if width == 0 and height == 0:
# return 1
#
# count = 0
# if width > 0: # go right
# count += count_path(width-1, height)
# if height > 0: # go down
# count += count_path(width, height-1)
#
# return count
#
#print count_path(20, 20)
|