Cody

Problem 2409. Find the Connecting Path

Solution 1719502

Submitted on 2 Feb 2019 by William
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 = [7 6 8 5 7 2 4 5 1 3 0 0 0;7 7 7 7 7 0 0 0 0 0 0 0 0;0 0 0 5 5 5 5 5 0 0 0 0 0;0 0 0 1 1 1 1 1 1 0 0 0 0;0 0 0 0 0 2 2 2 2 2 2 2 0;0 6 6 6 6 6 0 0 0 0 0 0 0;0 3 3 3 3 3 3 3 3 3 0 0 0;0 0 0 0 0 0 0 0 0 2 2 2 0;0 0 0 0 0 0 4 4 4 4 4 4 4;0 0 8 8 8 8 8 0 0 0 0 0 0;0 0 4 4 4 4 4 4 4 4 4 4 4;0 3 4 1 7 6 8 0 0 2 9 0 0]; n = 7; y_correct =[1 0 0 0 1 0 0 0 0 0 0 0 0;1 1 1 1 1 0 0 0 0 0 0 0 0;0 0 0 0 1 0 0 0 0 0 0 0 0;0 0 0 0 1 0 0 0 0 0 0 0 0;0 0 0 0 1 0 0 0 0 0 0 0 0;0 0 0 0 1 0 0 0 0 0 0 0 0;0 0 0 0 1 0 0 0 0 0 0 0 0;0 0 0 0 1 0 0 0 0 0 0 0 0;0 0 0 0 1 0 0 0 0 0 0 0 0;0 0 0 0 1 0 0 0 0 0 0 0 0;0 0 0 0 1 0 0 0 0 0 0 0 0;0 0 0 0 1 0 0 0 0 0 0 0 0]; assert(isequal(your_fcn_name(x,n),y_correct))

2   Pass
x = [7 6 8 5 7 2 4 5 1 3 0 0 0;7 7 7 7 7 0 0 0 0 0 0 0 0;0 0 0 5 5 5 5 5 0 0 0 0 0;0 0 0 1 1 1 1 1 1 0 0 0 0;0 0 0 0 0 2 2 2 2 2 2 2 0;0 6 6 6 6 6 0 0 0 0 0 0 0;0 3 3 3 3 3 3 3 3 3 0 0 0;0 0 0 0 0 0 0 0 0 2 2 2 0;0 0 0 0 0 0 4 4 4 4 4 4 4;0 0 8 8 8 8 8 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