Find the length of the shortest path through the matrix from the top left to bottom right corner. You may move right, down, or diagonally right-down one element at a time. The length of the path is the sum of the elements you pass through.
E.g.
M = [*8 6 10 10 4 7 7 7
9 *1 10 5 9 0 8 2
1 3 *2 8 8 8 7 7
9 5 10 *1 *10 *9 *4 *0 ];
>> shortest_path(M)
ans =
35
The shortest path through this matrix has length 35. Each element along the path is marked with a *
Solution Stats
Problem Comments
1 Comment
Solution Comments
Show comments
Loading...
Problem Recent Solvers82
Suggested Problems
-
6458 Solvers
-
It dseon't mettar waht oedrr the lrettes in a wrod are.
2161 Solvers
-
Project Euler: Problem 10, Sum of Primes
2129 Solvers
-
Sum the entries of each column of a matrix which satisfy a logical condition.
176 Solvers
-
Square Digits Number Chain Terminal Value (Inspired by Project Euler Problem 92)
265 Solvers
More from this Author5
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
Cool problem. Optimal solutions sometimes appear if moving up is enabled.