Project Euler 81: Find the minimal path sum from the top left to the bottom right by moving right and down.
Project Euler 81 Problem Description
Project Euler 81: In the 5 by 5 matrix below, the minimal path sum from the top left to the bottom right, by only moving to the right and down, is indicated in red and is equal to 2427.
131 | 673 | 234 | 103 | 18 |
201 | 96 | 342 | 965 | 150 |
630 | 803 | 746 | 422 | 111 |
537 | 699 | 497 | 121 | 956 |
805 | 732 | 524 | 37 | 331 |
Find the minimal path sum, in matrix.txt (right click and ‘Save Link/Target As…’), a 31K text file containing a 80 by 80 matrix, from the top left to the bottom right by only moving right and down.
Analysis
As with problems 18 & 67 we have a designated starting and ending place. We can use the same technique used to solve those problems by starting at the top-left and moving down, to the right, replacing each column with minimal sums. See those problems for further information.
Project Euler 81 Solution
Runs < 0.001 seconds in Python 2.7.Use this link to get the Project Euler 81 Solution Python 2.7 source.
Afterthoughts
- See also, Project Euler 18 Solution:
- See also, Project Euler 67 Solution:
- See also, Project Euler 82 Solution:
if i*j>0
is the same asif i>0 and j>0
, for non-negative integers
Project Euler 81
Discussion
No comments yet.