Cody

Solution 1698278

Submitted on 21 Dec 2018
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   Fail
a = ones(3) - eye(3); b = zeros(3); mat = [a b; b a]; n = 2; assert(isequal(cComponents(mat),n))

L = 2 -1 -1 0 0 0 -1 2 -1 0 0 0 -1 -1 2 0 0 0 0 0 0 2 -1 -1 0 0 0 -1 2 -1 0 0 0 -1 -1 2 y = 3

Assertion failed.

2   Fail
a = randi(20); mat = ones(a) - eye(a); n = 1; assert(isequal(cComponents(mat),n))

L = 6 -1 -1 -1 -1 -1 -1 -1 6 -1 -1 -1 -1 -1 -1 -1 6 -1 -1 -1 -1 -1 -1 -1 6 -1 -1 -1 -1 -1 -1 -1 6 -1 -1 -1 -1 -1 -1 -1 6 -1 -1 -1 -1 -1 -1 -1 6 y = 2

Assertion failed.

3   Fail
mat = [0 1 0 0 1; 1 0 1 0 0; 0 1 0 1 0; 0 0 1 0 1; 1 0 0 1 0]; assert(isequal(cComponents(mat),1))

L = 2 -1 0 0 -1 -1 2 -1 0 0 0 -1 2 -1 0 0 0 -1 2 -1 -1 0 0 -1 2 y = 2

Assertion failed.

4   Fail
a = ones(3) - eye(3); b = zeros(3); mat = [a b b; b a b; b b a]; n = 3; assert(isequal(cComponents(mat),n))

L = 2 -1 -1 0 0 0 0 0 0 -1 2 -1 0 0 0 0 0 0 -1 -1 2 0 0 0 0 0 0 0 0 0 2 -1 -1 0 0 0 0 0 0 -1 2 -1 0 0 0 0 0 0 -1 -1 2 0 0 0 0 0 0 0 0 0 2 -1 -1 0 0 0 0 0 0 -1 2 -1 0 0 0 0 0 0 -1 -1 2 y = 4

Assertion failed.

5   Fail
a = ones(3) - eye(3); b = zeros(3); p = floor((randi(20)+3)/3)*3; mat = []; for i= 1:p c = [repmat(b,1,i-1) a repmat(b,1,p-i)]; mat = [mat;c]; end assert(isequal(cComponents(mat),p))

L = 2 -1 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 2 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 -1 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 -1 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 2 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 -1 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 -1 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 2 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 -1 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 -1 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 2 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 -1 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 -1 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 2 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 -1 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 -1 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 2 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 -1 2 y = 7

Assertion failed.

Suggested Problems

More from this Author44