Cody

Solution 1577834

Submitted on 7 Jul 2018 by Radha Kumari
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
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))

ans = 1 0 0 1 ans = 1 1 1 1

2   Pass
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))

ans = 1 0 0 1 ans = 1 1 1 1

3   Pass
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))

ans = 1 ans = 2

4   Pass
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))

ans = 0.7235 0.4787 0.0003 0.0491 0.0397 0.7322 ans = 0.8645 0.5124 0.8641 0.6108 0.3126 0.4553

5   Pass
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))

ans = 0.9131 0.9914 0.5892 0.4088 0.6501 0.4585 ans = 0.1531 0.1823 0.1193 0.6005 0.6897 0.3711

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

ans = [] ans = []