Project Euler - Problem 15


/ Published in: Python
Save to your folder(s)



Copy this code and paste it in your HTML
  1. #!/usr/bin/python
  2.  
  3. # Project Euler - Problem 15
  4.  
  5. print "\nProject Euler - Problem 15"
  6. print "Find the number of paths in a 20x20 grid to the bottom right corner.\n"
  7.  
  8. x= []
  9. grid = 20
  10.  
  11. for i in xrange(grid+1):
  12. x.append([1])
  13. x[0].append(1)
  14.  
  15. for m in range(1,grid+1):
  16. for n in range(1,grid+1):
  17. x[m].append(x[m-1][n] + x[m][n-1])
  18.  
  19. print x[grid][grid]

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.