We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.

- All Contests
- ProjectEuler+
- Project Euler #83: Path sum: four ways

# Project Euler #83: Path sum: four ways

# Project Euler #83: Path sum: four ways

Contest ends in

_{This problem is a programming version of Problem 83 from projecteuler.net}

In the matrix below, the minimal path sum from the top left to the bottom right, by moving left, right, up, and down, is indicated in bold red and is equal to .

Find the minimum path sum in given matrix.

**Input Format**

Each testcase begins with an integer followed by lines containing the description of the matrix.

**Constraints**

**Output Format**

A single line for each testcase containing the value of the minimal path sum.

**Sample Input**

```
5
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
```

**Sample Output**

```
2297
```