/ Published in: Python
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
#!/usr/bin/python # Project Euler - Problem 15 print "\nProject Euler - Problem 15" print "Find the number of paths in a 20x20 grid to the bottom right corner.\n" x= [] grid = 20 for i in xrange(grid+1): x.append([1]) x[0].append(1) for m in range(1,grid+1): for n in range(1,grid+1): x[m].append(x[m-1][n] + x[m][n-1]) print x[grid][grid]