(23 votes, average: 4.83 out of 5)

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.

This program and method
solves all test cases for
Project Euler 81 on HackerRank

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

Project Euler 81

Project Euler 81 Solution last updated