## 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.

#### Answer

Slowly swipe from either end beginning with the white vertical bar to get an idea of the starting or ending digits. For less drama, just double click the answer area. The distance between the two bars will give you an idea of the magnitude. Touch devices can tap and hold the center of the box between the two bars and choose*define*to reveal the answer.

#### Afterthoughts

- See also, Project Euler 18 Solution: Maximum sum from top to bottom of triangular array.
- See also, Project Euler 67 Solution: Find the maximum total from top to bottom in a large triangle of numbers using an efficient algorithm.
- See also, Project Euler 82 Solution: Find the minimal path sum from the left column to the right column.
`if i*j>0`

is the same as`if i>0 and j>0`

, for non-negative integers

Project Euler 81

*Project Euler 81 Solution last updated*

## Discussion

## No comments yet.