Cody

Solution 1938742

Submitted on 17 Sep 2019
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
P = [1 0; 1 2]; m1 = eye(2); m2 = ones(2); M_correct = [1 0 0 0; 0 1 0 0; 1 0 1 1; 0 1 1 1]; assert(isequal(patchworkMatrix(P,m1,m2),M_correct))

M = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ans = 1 2 ans = 1 2 ans = 1 ans = 1 2 ans = 1 2 ans = 1 ans = -1 0 ans = 1 2 ans = 0

Index in position 1 is invalid. Array indices must be positive integers or logical values. Error in patchworkMatrix (line 11) M((x-1)*s(1)+(1:s(1)),(y-1)*s(2)+(1:s(2))) = varargin{max(P(i),1)}*logical(P(i)); Error in Test1 (line 5) assert(isequal(patchworkMatrix(P,m1,m2),M_correct))

2   Fail
P = 2-eye(4); m1 = eye(2); m2 = ones(2); M_correct = [1 0 1 1 1 1 1 1; 0 1 1 1 1 1 1 1; 1 1 1 0 1 1 1 1; 1 1 0 1 1 1 1 1; 1 1 1 1 1 0 1 1; 1 1 1 1 0 1 1 1; 1 1 1 1 1 1 1 0; 1 1 1 1 1 1 0 1]; assert(isequal(patchworkMatrix(P,m1,m2),M_correct))

M = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ans = 1 2 ans = 1 2 ans = 1 ans = 3 4 ans = 1 2 ans = 2 ans = 3 4 ans = 1 2 ans = 2 ans = 3 4 ans = 1 2 ans = 2 ans = 3 4 ans = 1 2 ans = 2 ans = 1 2 ans = 1 2 ans = 1 ans = 3 4 ans = 1 2 ans = 2 ans = 3 4 ans = 1 2 ans = 2 ans = 3 4 ans = 1 2 ans = 2 ans = 3 4 ans = 1 2 ans = 2 ans = 1 2 ans = 1 2 ans = 1 ans = 3 4 ans = 1 2 ans = 2 ans = 3 4 ans = 1 2 ans = 2 ans = 3 4 ans = 1 2 ans = 2 ans = 3 4 ans = 1 2 ans = 2 ans = 1 2 ans = 1 2 ans = 1 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 1 1 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

Assertion failed.

3   Fail
P = [2 3 2 3]; m1 = 1; m2 = 2; m3 = 3; M_correct = [2 3 2 3]; assert(isequal(patchworkMatrix(P,m1,m2,m3),M_correct))

M = 0 0 0 0 ans = 1 ans = 2 ans = 2 ans = 1 ans = 3 ans = 3 ans = 1 ans = 2 ans = 2 ans = 1 ans = 3 ans = 3 0 2 3 0

Assertion failed.

4   Fail
P = [6 5; 4 3; 2 1]; m1 = rand(2,3); m2 = rand(2,3); m3 = rand(2,3); m4 = rand(2,3); m5 = rand(2,3); m6 = rand(2,3); M_correct = [m6 m5; m4 m3; m2 m1]; assert(isequal(patchworkMatrix(P,m1,m2,m3,m4,m5,m6),M_correct))

M = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ans = 5 6 ans = 4 5 6 ans = 6 ans = 1 2 ans = 4 5 6 ans = 4 ans = 3 4 ans = 1 2 3 ans = 2 ans = 3 4 ans = 4 5 6 ans = 5 ans = 5 6 ans = 1 2 3 ans = 3 ans = 1 2 ans = 1 2 3 ans = 1 0.2778 0.6187 0.8431 0.1884 0.9683 0.2510 0.0212 0.7635 0.6363 0.2192 0.1784 0.3377 0.9481 0.3994 0.9778 0.7953 0.4160 0.1150 0.5381 0.8964 0.6096 0.9240 0.5342 0.9296 0.8233 0.9418 0.9924 0.5565 0.3777 0.0881 0.0079 0.2115 0.7834 0.4745 0.3484 0.0230

Assertion failed.

5   Fail
P = zeros(2); m1 = rand(3,2); m2 = rand(3,2); m3 = rand(3,2); m4 = rand(3,2); m5 = rand(3,2); m6 = rand(3,2); M_correct = zeros(6,4); assert(isequal(patchworkMatrix(P,m1,m2,m3,m4,m5,m6),M_correct))

M = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ans = -2 -1 0 ans = 1 2 ans = 0

Index in position 1 is invalid. Array indices must be positive integers or logical values. Error in patchworkMatrix (line 11) M((x-1)*s(1)+(1:s(1)),(y-1)*s(2)+(1:s(2))) = varargin{max(P(i),1)}*logical(P(i)); Error in Test5 (line 9) assert(isequal(patchworkMatrix(P,m1,m2,m3,m4,m5,m6),M_correct))

6   Pass
P = []; m = cell(100); assert(isempty(patchworkMatrix(P,m{:})))

M = []