Cody

Problem 2409. Find the Connecting Path

Solution 564413

Submitted on 24 Jan 2015
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   Fail
%% 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 = 4; y_correct =[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 1 1 1 1 1 1;0 0 0 0 0 0 0 0 0 0 0 0 1;0 0 1 1 1 1 1 1 1 1 1 1 1;0 0 1 0 0 0 0 0 0 0 0 0 0] assert(isequal(your_fcn_name(x,n),y_correct))

Error: Assertion failed.

Suggested Problems

Community Treasure Hunt

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

Start Hunting!