Cody

Problem 45458. Minimal Path - 03

Solution 2230874

Submitted on 23 Apr 2020 by atsushi maruyama
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 =[1 12 4 6 8 10 100 ; 1 5 7 87 98 2 200;20 56 74 1 34 56 21] y_correct = [1 4 7 10 13 16 17 18 21]; assert(isequal(minimal_path_4(x),y_correct))

x = 1 12 4 6 8 10 100 1 5 7 87 98 2 200 20 56 74 1 34 56 21 pathidx = 1 2 3 6 9 12 15 18 21 1 2 5 6 9 12 15 18 21 1 2 5 8 9 12 15 18 21 1 2 5 8 11 12 15 18 21 1 2 5 8 11 14 15 18 21 1 2 5 8 11 14 17 18 21 1 2 5 8 11 14 17 20 21 1 4 5 6 9 12 15 18 21 1 4 5 8 9 12 15 18 21 1 4 5 8 11 12 15 18 21 1 4 5 8 11 14 15 18 21 1 4 5 8 11 14 17 18 21 1 4 5 8 11 14 17 20 21 1 4 7 8 9 12 15 18 21 1 4 7 8 11 12 15 18 21 1 4 7 8 11 14 15 18 21 1 4 7 8 11 14 17 18 21 1 4 7 8 11 14 17 20 21 1 4 7 10 11 12 15 18 21 1 4 7 10 11 14 15 18 21 1 4 7 10 11 14 17 18 21 1 4 7 10 11 14 17 20 21 1 4 7 10 13 14 15 18 21 1 4 7 10 13 14 17 18 21 1 4 7 10 13 14 17 20 21 1 4 7 10 13 16 17 18 21 1 4 7 10 13 16 17 20 21 1 4 7 10 13 16 19 20 21 y1 = 1 4 7 10 13 16 17 18 21 row = 1 0 1 2 3 3 3 3 3 3 3 1 0 1 2 2 3 3 3 3 3 3 1 0 1 2 2 2 3 3 3 3 3 1 0 1 2 2 2 2 3 3 3 3 1 0 1 2 2 2 2 2 3 3 3 1 0 1 2 2 2 2 2 2 3 3 1 0 1 2 2 2 2 2 2 2 3 1 0 1 1 2 3 3 3 3 3 3 1 0 1 1 2 2 3 3 3 3 3 1 0 1 1 2 2 2 3 3 3 3 1 0 1 1 2 2 2 2 3 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3 1 2 1 1 1 1 2 2 2 3 3 1 2 1 1 1 1 2 2 2 2 3 1 2 1 1 1 1 1 2 3 3 3 1 2 1 1 1 1 1 2 2 3 3 1 2 1 1 1 1 1 2 2 2 3 1 2 1 1 1 1 1 1 2 3 3 1 2 1 1 1 1 1 1 2 2 3 1 2 1 1 1 1 1 1 1 2 3 1 2 3 2 3 3 3 3 3 3 3 1 2 3 2 2 3 3 3 3 3 3 1 2 3 2 2 2 3 3 3 3 3 1 2 3 2 2 2 2 3 3 3 3 1 2 3 2 2 2 2 2 3 3 3 1 2 3 2 2 2 2 2 2 3 3 1 2 3 2 2 2 2 2 2 2 3 1 2 3 1 3 3 3 3 3 3 3 1 2 3 1 1 3 3 3 3 3 3 1 2 3 1 1 1 3 3 3 3 3 1 2 3 1 1 1 1 3 3 3 3 ...

2   Pass
x =[1 122 4 6 8 10 100 ; 1 5 7 87 98 2 200;20 56 74 1 34 56 21] y_correct = [1 2 5 8 7 10 13 16 17 18 21]; assert(isequal(minimal_path_4(x),y_correct))

x = 1 122 4 6 8 10 100 1 5 7 87 98 2 200 20 56 74 1 34 56 21 pathidx = 1 2 3 6 9 12 15 18 21 1 2 5 6 9 12 15 18 21 1 2 5 8 9 12 15 18 21 1 2 5 8 11 12 15 18 21 1 2 5 8 11 14 15 18 21 1 2 5 8 11 14 17 18 21 1 2 5 8 11 14 17 20 21 1 4 5 6 9 12 15 18 21 1 4 5 8 9 12 15 18 21 1 4 5 8 11 12 15 18 21 1 4 5 8 11 14 15 18 21 1 4 5 8 11 14 17 18 21 1 4 5 8 11 14 17 20 21 1 4 7 8 9 12 15 18 21 1 4 7 8 11 12 15 18 21 1 4 7 8 11 14 15 18 21 1 4 7 8 11 14 17 18 21 1 4 7 8 11 14 17 20 21 1 4 7 10 11 12 15 18 21 1 4 7 10 11 14 15 18 21 1 4 7 10 11 14 17 18 21 1 4 7 10 11 14 17 20 21 1 4 7 10 13 14 15 18 21 1 4 7 10 13 14 17 18 21 1 4 7 10 13 14 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 11 15 16 20 1 2 6 10 11 15 19 20 1 2 6 10 14 15 16 20 1 2 6 10 14 15 19 20 1 2 6 10 14 18 19 20 1 5 6 7 8 12 16 20 1 5 6 7 11 12 16 20 1 5 6 7 11 15 16 20 1 5 6 7 11 15 19 20 1 5 6 10 11 12 16 20 1 5 6 10 11 15 16 20 1 5 6 10 11 15 19 20 1 5 6 10 14 15 16 20 1 5 6 10 14 15 19 20 1 5 6 10 14 18 19 20 1 5 9 10 11 12 16 20 1 5 9 10 11 15 16 20 1 5 9 10 11 15 19 20 1 5 9 10 14 15 16 20 1 5 9 10 14 15 19 20 1 5 9 10 14 18 19 20 1 5 9 13 14 15 16 20 1 5 9 13 14 15 19 20 1 5 9 13 14 18 19 20 1 5 9 13 17 18 19 20 y1 = 1 5 6 7 8 12 16 20 row = 1 0 1 2 3 4 4 4 4 4 1 0 1 2 3 3 4 4 4 4 1 0 1 2 3 3 3 4 4 4 1 0 1 2 3 3 3 3 4 4 1 0 1 2 3 3 3 3 3 4 1 0 1 2 2 3 4 4 4 4 1 0 1 2 2 3 3 4 4 4 1 0 1 2 2 3 3 3 4 4 1 0 1 2 2 3 3 3 3 4 1 0 1 2 2 2 3 4 4 4 1 0 1 2 2 2 3 3 4 4 1 0 1 2 2 2 3 3 3 4 1 0 1 2 2 2 2 3 4 4 1 0 1 2 2 2 2 3 3 4 1 0 1 2 2 2 2 2 3 4 1 0 1 1 2 3 4 4 4 4 1 0 1 1 2 3 3 4 4 4 1 0 1 1 2 3 3 3 4 4 1 0 1 1 2 3 3 3 3 4 1 0 1 1 2 2 3 4 4 4 1 0 1 1 2 2 3 3 4 4 1 0 1 1 2 2 3 3 3 4 1 0 1 1 2 2 2 3 4 4 1 0 1 1 2 2 2 3 3 4 1 0 1 1 2 2 2 2 3 4 1 0 1 1 1 2 3 4 4 4 1 0 1 1 1 2 3 3 4 4 1 0 1 1 1 2 3 3 3 4 1 0 1 1 1 2 2 3 4 4 1 0 1 1 1 2 2 3 3 4 1 0 1 1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 4 4 1 2 3 4 4 3 3 3 3 4 1 2 3 4 4 ...

4   Pass
x=[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]; y_correct = [1 2 7 12 13 18 19 20 25]; assert(isequal(minimal_path_4(x),y_correct))

pathidx = 1 2 3 4 5 10 15 20 25 1 2 3 4 9 10 15 20 25 1 2 3 4 9 14 15 20 25 1 2 3 4 9 14 19 20 25 1 2 3 4 9 14 19 24 25 1 2 3 8 9 10 15 20 25 1 2 3 8 9 14 15 20 25 1 2 3 8 9 14 19 20 25 1 2 3 8 9 14 19 24 25 1 2 3 8 13 14 15 20 25 1 2 3 8 13 14 19 20 25 1 2 3 8 13 14 19 24 25 1 2 3 8 13 18 19 20 25 1 2 3 8 13 18 19 24 25 1 2 3 8 13 18 23 24 25 1 2 7 8 9 10 15 20 25 1 2 7 8 9 14 15 20 25 1 2 7 8 9 14 19 20 25 1 2 7 8 9 14 19 24 25 1 2 7 8 13 14 15 20 25 1 2 7 8 13 14 19 20 25 1 2 7 8 13 14 19 24 25 1 2 7 8 13 18 19 20 25 1 2 7 8 13 18 19 24 25 1 2 7 8 13 18 23 24 25 1 2 7 12 13 14 15 20 25 1 2 7 12 13 14 19 20 25 1 2 7 12 13 14 19 24 25 1 2 7 12 13 18 19 20 25 1 2 7 12 13 18 19 24 25 1 2 7 12 13 18 23 24 25 1 2 7 12 17 18 19 20 25 1 2 7 12 17 18 19 24 25 1 2 7 12 17 18 23 24 25 1 2 7 12 17 22 23 24 25 1 6 7 8 9 10 15 20 25 1 6 7 8 9 14 15 20 25 1 6 7 8 9 14 19 20 25 1 6 7 8 9 14 19 24 25 1 6 7 8 13 14 15 20 25 1 6 7 8 13 14 19 20 25 1 6 7 8 13 14 19 24 25 1 6 7 8 13 18 19 20 25 1 6 7 8 13 18 19 24 25 1 6 7 8 13 18 23 24 25 1 6 7 12 13 14 15 20 25 1 6 7 12 13 14 19 20 25 1 6 7 12 13 14 19 24 25 1 6 7 12 13 18 19 20 25 1 6 7 12 13 18 19 24 25 1 6 7 12 13 18 23 24 25 1 6 7 12 17 18 19 20 25 1 6 7 12 17 18 19 24 25 1 6 7 12 17 18 23 24 25 1 6 7 12 17 22 23 24 25 1 6 11 12 13 14 15 20 25 1 6 11 12 13 14 19 20 25 1 6 11 12 13 14 19 24 25 1 6 11 12 13 18 19 20 25 1 6 11 12 13 18 19 24 25 1 6 11 12 13 18 23 24 25 1 6 11 12 17 18 19 20 25 1 6 11 12 17 18 19 24 25 1 6 11 12 17 18 23 24 25 1 6 11 12 17 22 23 24 25 1 6 11 16 17 18 19 20 25 1 6 11 16 17 18 19 24 25 1 6 11 16 17 18 23 24 25 1 6 11 16 17 22 23 24 25 1 6 11 16 21 22 23 24 25 y1 = 1 2 7 12 13 18 19 20 25 row = 1 0 1 2 3 4 5 5 5 5 5 1 0 1 2 3 4 4 5 5 5 5 1 0 1 2 3 4 4 4 5 5 5 1 0 1 2 3 4 4 4 4 5 5 1 0 1 2 3 4 4 4 4 4 5 1 0 1 2 3 3 4 5 5 5 5 1 0 1 2 3 3 4 4 5 5 5 1 0 1 2 3 3 4 4 4 5 5 1 0 1 2 3 3 4 4 4 4 5 1 0 1 2 3 3 3 4 5 5 5 1 0 1 2 3 3 3 4 4 5 5 1 0 1 2 3 3 3 4 4 4 5 1 0 1 2 3 3 3 3 4 5 5 1 0 1 2 3 3 3 3 4 4 5 1 0 1 2 3 3 3 3 3 4 5 1 0 1 2 2 3 4 5 5 5 5 1 0 1 2 2 3 4 4 5 5 5 1 0 1 2 2 3 4 4 4 5 5 1 0 1 2 2 3 4 4 4 4 5 1 0 1 2 2 3 3 4 5 5 5 1 0 1 2 2 3 3 4 4 5 5 1 0 1 2 2 3 3 4 4 4 5 1 0 1 2 2 3 3 3 4 5 5 1 0 1 2 2 3 3 3 4 4 5 1 0 1 2 2 3 3 3 3 4 5 1 0 1 2 2 2 3 4 5 5 5 1 0 1 2 2 2 3 4 4 5 5 1 0 1 2 2 2 3 4 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1 2 3 3 4 5 5 5 1 0 5 1 2 3 3 4 4 5 5 1 0 5 1 2 3 3 4 4 4 5 1 0 5 1 2 3 3 3 4 5 5 1 0 5 1 2 3 3 3 4 4 5 1 0 5 1 2 3 3 3 3 4 5 1 0 5 1 2 2 3 4 5 5 5 1 0 5 1 2 2 3 4 4 5 5 1 0 5 1 2 2 3 4 4 4 5 1 0 5 1 2 2 3 3 4 5 5 1 0 5 1 2 2 3 3 4 4 5 1 0 5 1 2 2 3 3 3 4 5 1 0 5 1 2 2 2 3 4 5 5 1 0 5 1 2 2 2 3 4 4 5 1 0 5 1 2 2 2 3 3 4 5 1 0 5 1 2 2 2 2 3 4 5 1 0 5 1 1 2 ...

Suggested Problems

More from this Author149

Community Treasure Hunt

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

Start Hunting!