Problem 2534. Path of least resistance - Move all direction

Extension of the wonderful Problem 1049 (Path of Least Resistance).
A matrix is given as input. You have to take a tour starting from the top left corner to the bottom right corner of the matrix. You can move to any one of the adjacent 8 elements. Return only the sum of the elements in your path.
Example :
Input = [1 9 1 1
9 1 9 1
1 3 9 1
9 9 8 1];
Output = 7;
Here, the least-sum path though the matrix is shown below with asterisk(*):
[1* 9 1* 1*
9 1* 9 1*
1 3 9 1*
9 9 8 1*];
Return only the sum of the elements along the path. I will add robust test cases time to time WITHOUT re-scoring existing solutions.

Solution Stats

28.57% Correct | 71.43% Incorrect
Last Solution submitted on Oct 21, 2023

Problem Comments

Solution Comments

Show comments

Problem Recent Solvers20

Suggested Problems

More from this Author44

Problem Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!