Problem 2534. Path of least resistance - Move all direction
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
Problem Comments
-
7 Comments
Show
4 older comments
rifat
on 2 Sep 2014
May be you are considering the element at the bottom left corner. But, it is not necessary since diagonal movement is also allowed
Paul Berglund
on 3 Sep 2014
OK, you're right about test case 2. I was wrong. But I get 6 for test case 1, not 7. The shortest path does not include upper right corner.
rifat
on 4 Sep 2014
yeah, that is wrong.. corrected and thanks. too many mistake in a single problem
Solution Comments
Show commentsGroup

Board Games II
- 14 Problems
- 10 Finishers
- High Precision Square Root (Inspired by Project Euler 80)
- Damping of Servomotors with Tachometer Feedback
- Find the right number make the equation
- Deriving a function using the difference quotient
- Fast 1-D Convolution (full shape)
- Fast 1-D Convolution (same shape)
- Fast 1-D Convolution (valid shape)
- Lambert's W
- First use of arrayfun() and anonymous function @(x)
- Cell Operator *
- Product of two multivariate polynomials
- Multivariate polynomials - convert monomial form to array
- Multivariate polynomials - overload multiplication
- Multivariate polynomials - emulate symbolic form
- Rewrite setdiff to account for non-unique values
Problem Recent Solvers21
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!