Cody

# Problem 45457. Minimal Path - 02

Solution 2555112

Submitted on 14 Jun 2020
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

### Test Suite

Test Status Code Input and Output
1   Pass
x = [2 2 2 2 2 10 10 10 1 2 20 20 20 1 2 30 30 30 30 2] y=[1 5 9 13 14 15 19 20] assert(isequal(minimal_path_3(x),y))

x = 2 2 2 2 2 10 10 10 1 2 20 20 20 1 2 30 30 30 30 2 y = 1 5 9 13 14 15 19 20 ans = 1 5 9 13 14 15 19 20

2   Pass
x = [2 2 2 2 2 0 0 10 1 2 20 0 20 1 2 30 0 0 3 2] y=[1 2 6 7 8 12 16 20] assert(isequal(minimal_path_3(x),y))

x = 2 2 2 2 2 0 0 10 1 2 20 0 20 1 2 30 0 0 3 2 y = 1 2 6 7 8 12 16 20 ans = 1 2 6 7 8 12 16 20

3   Pass
x = [100 20 30 40 50 60 70 80 90 100] y=[1 3 5 7 9 10] assert(isequal(minimal_path_3(x),y))

x = 100 20 30 40 50 60 70 80 90 100 y = 1 3 5 7 9 10 ans = 1 3 5 7 9 10

4   Fail
x = [11 111 23 45 67 -500 34 23 22 32 432 1234 12 1244 -544 44 1 2 3 4 5 6 7 8 -12000 45 6 7 8 433 664 2344]; y=[1 2 3 4 8 12 16 20 24 28 32] assert(isequal(minimal_path_3(x),y))

y = 1 2 3 4 8 12 16 20 24 28 32

Error using graph/shortestpath (line 92) Graph edge weights must be nonnegative. Error in minimal_path_3 (line 18) shortestpath(g,1,m*n) Error in Test4 (line 6) assert(isequal(minimal_path_3(x),y))

5   Pass
%x=magic(10); %y=[ 1 11 21 22 32 42 43 44 45 55 56 57 58 68 69 79 89 90 100]; %assert(isequal(minimal_path_3(x),y))

### Community Treasure Hunt

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

Start Hunting!