Cody

# Problem 591. Create a patchwork matrix

Solution 3366998

Submitted on 24 Oct 2020
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))

m1 = 1 0 0 1 m2 = 1 1 1 1 A = 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 A = 1 0 0 0 0 1 0 0 1 0 0 0 0 1 0 0 A = 1 0 0 0 0 1 0 0 1 0 1 1 0 1 1 1

Output argument "M" (and maybe others) not assigned during call to "patchworkMatrix". 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))

m1 = 1 0 0 1 m2 = 1 1 1 1 A = 1 0 0 0 0 0 0 0 0 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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 A = 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 A = 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 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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 1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0 A = 1 0 1 1 1 1 0 0 0 1 1 1 1 1 0 0 1 1 1 0 1 1 0 0 1 1 0 1 1 1 0 0 1 1 1 1 1 0 0 0 1 1 1 1 0 1 0 0 1 1 1 1 1 1 0 0 1 1 1 1 1 1 0 0 A = 1 0 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 0 1 1 0 0 1 1 0 1 1 1 0 0 1 1 1 1 1 0 0 0 1 1 1 1 0 1 0 0 1 1 1 1 1 1 0 0 1 1 1 1 1 1 0 0 A = 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 0 0 1 1 1 1 0 1 0 0 1 1 1 1 1 1 0 0 1 1 1 1 1 1 0 0 A = 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 0 0 1 1 1 1 1 1 0 0 A = 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

Output argument "M" (and maybe others) not assigned during call to "patchworkMatrix". Error in Test2 (line 5) assert(isequal(patchworkMatrix(P,m1,m2),M_correct))

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

m1 = 1 m2 = 2 A = 2 3 2 3

Output argument "M" (and maybe others) not assigned during call to "patchworkMatrix". Error in Test3 (line 6) assert(isequal(patchworkMatrix(P,m1,m2,m3),M_correct))

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

m1 = 0.3085 0.7510 0.4495 0.9751 0.4203 0.1085 m2 = 0.8015 0.9480 0.3612 0.5791 0.7576 0.4861

Unrecognized function or variable 'm6'. Error in patchworkMatrix (line 10) A = [m6 m5; m4 m3; m2 m1] Error in Test4 (line 9) assert(isequal(patchworkMatrix(P,m1,m2,m3,m4,m5,m6),M_correct))

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

m1 = 0.8060 0.5721 0.2848 0.9486 0.6168 0.1502 m2 = 0.7650 0.5012 0.4069 0.1374 0.6076 0.6735

Output argument "M" (and maybe others) not assigned during call to "patchworkMatrix". Error in Test5 (line 9) assert(isequal(patchworkMatrix(P,m1,m2,m3,m4,m5,m6),M_correct))

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

m1 = [] m2 = []

Output argument "M" (and maybe others) not assigned during call to "patchworkMatrix". Error in Test6 (line 3) assert(isempty(patchworkMatrix(P,m{:})))

### Community Treasure Hunt

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

Start Hunting!