diff options
| author | Reiner Herrmann <reiner@reiner-h.de> | 2009-10-21 12:13:11 +0200 |
|---|---|---|
| committer | Reiner Herrmann <reiner@reiner-h.de> | 2014-08-31 20:10:58 +0200 |
| commit | bd24a1a21abb828076cb3e4b5ebe2ef48220f27f (patch) | |
| tree | 68b41d580a063e3382acf153e7e498716209e4da | |
| parent | 81e497809b405c9cb9789efe1d0ee44fad38b54f (diff) | |
project euler solution 15
| -rw-r--r-- | src/projecteuler/015.py | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/projecteuler/015.py b/src/projecteuler/015.py new file mode 100644 index 0000000..749be04 --- /dev/null +++ b/src/projecteuler/015.py @@ -0,0 +1,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) + |
