Cody

Solution 1941796

Submitted on 18 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
M=[1 4 7 10; 2 5 8 11; 3 6 9 12]; R=2;C=3; X(:,:,1) =[1 4 7 ; 2 5 8]; X(:,:,2) =[2 5 8 ; 3 6 9]; X(:,:,3) =[4 7 10 ; 5 8 11]; X(:,:,4) =[5 8 11 ; 6 9 12]; assert(isequal(BreakTheMatrix(M,R,C),X))

y = 1 4 7 2 5 8 y(:,:,1) = 1 4 7 2 5 8 y(:,:,2) = 1 4 7 2 5 8

Assertion failed.

2   Fail
x=1:ceil(35+25*rand());r=1;c=1; M=BreakTheMatrix(x,r,c); assert(all(arrayfun(@(y) (M(:,:,y)==y),1:numel(x))))

y = 1 y(:,:,1) = 1 y(:,:,2) = 1 y(:,:,1) = 1 y(:,:,2) = 1 y(:,:,3) = 1 y(:,:,1) = 1 y(:,:,2) = 1 y(:,:,3) = 1 y(:,:,4) = 1 y(:,:,1) = 1 y(:,:,2) = 1 y(:,:,3) = 1 y(:,:,4) = 1 y(:,:,5) = 1 y(:,:,1) = 1 y(:,:,2) = 1 y(:,:,3) = 1 y(:,:,4) = 1 y(:,:,5) = 1 y(:,:,6) = 1 y(:,:,1) = 1 y(:,:,2) = 1 y(:,:,3) = 1 y(:,:,4) = 1 y(:,:,5) = 1 y(:,:,6) = 1 y(:,:,7) = 1 y(:,:,1) = 1 y(:,:,2) = 1 y(:,:,3) = 1 y(:,:,4) = 1 y(:,:,5) = 1 y(:,:,6) = 1 y(:,:,7) = 1 y(:,:,8) = 1 y(:,:,1) = 1 y(:,:,2) = 1 y(:,:,3) = 1 y(:,:,4) = 1 y(:,:,5) = 1 y(:,:,6) = 1 y(:,:,7) = 1 y(:,:,8) = 1 y(:,:,9) = 1 y(:,:,1) = 1 y(:,:,2) = 1 y(:,:,3) = 1 y(:,:,4) = 1 y(:,:,5) = 1 y(:,:,6) = 1 y(:,:,7) = 1 y(:,:,8) = 1 y(:,:,9) = 1 y(:,:,10) = 1 y(:,:,1) = 1 y(:,:,2) = 1 y(:,:,3) = 1 y(:,:,4) = 1 y(:,:,5) = 1 y(:,:,6) = 1 y(:,:,7) = 1 y(:,:,8) = 1 y(:,:,9) = 1 y(:,:,10) = 1 y(:,:,11) = 1 y(:,:,1) = 1 y(:,:,2) = 1 y(:,:,3) = 1 y(:,:,4) = 1 y(:,:,5) = 1 y(:,:,6) = 1 y(:,:,7) = 1 y(:,:,8) = 1 y(:,:,9) = 1 y(:,:,10) = 1 y(:,:,11) = 1 y(:,:,12) = 1 y(:,:,1) = 1 y(:,:,2) = 1 y(:,:,3) = 1 y(:,:,4) = 1 y(:,:,5) = 1 y(:,:,6) = 1 y(:,:,7) = 1 y(:,:,8) = 1 y(:,:,9) = 1 y(:,:,10) = 1 y(:,:,11) = 1 y(:,:,12) = 1 y(:,:,13) = 1 y(:,:,1) = 1 y(:,:,2) = 1 y(:,:,3) = 1 y(:,:,4) = 1 y(:,:,5) = 1 y(:,:,6) = 1 y(:,:,7) = 1 y(:,:,8) = 1 y(:,:,9) = 1 y(:,:,10) = 1 y(:,:,11) = 1 y(:,:,12) = 1 y(:,:,13) = 1 y(:,:,14) = 1 y(:,:,1) = 1 y(:,:,2) = 1 y(:,:,3) = 1 y(:,:,4) = 1 y(:,:,5) = 1 y(:,:,6) = 1 y(:,:,7) = 1 y(:,:,8) = 1 y(:,:,9) = 1 y(:,:,10) = 1 y(:,:,11) = 1 y(:,:,12) = 1 y(:,:,13) = 1 y(:,:,14) = 1 y(:,:,15) = 1 y(:,:,1) = 1 y(:,:,2) = 1 y(:,:,3) = 1 y(:,:,4) = 1 y(:,:,5) = 1 y(:,:,6) = 1 y(:,:,7) = 1 y(:,:,8) = 1 y(:,:,9) = 1 y(:,:,10) = 1 y(:,:,11) = 1 y(:,:,12) = 1 y(:,:,13) = 1 y(:,:,14) = 1 y(:,:,15) = 1 y(:,:,16) = 1 y(:,:,1) = 1 y(:,:,2) = 1 y(:,:,3) = 1 y(:,:,4) = 1 y(:,:,5) = 1 y(:,:,6) = 1 y(:,:,7) = 1 y(:,:,8) = 1 y(:,:,9) = 1 y(:,:,10) = 1 y(:,:,11) = 1 y(:,:,12) = 1 y(:,:,13) = 1 y(:,:,14) = 1 y(:,:,15) = 1 y(:,:,16) = 1 y(:,:,17) = 1 y(:,:,1) = 1 y(:,:,2) = 1 y(:,:,3) = 1 y(:,:,4) = 1 y(:,:,5) = 1 y(:,:,6) = 1 y(:,:,7) = 1 y(:,:,8) = 1 y(:,:,9) = 1 y(:,:,10) = 1 y(:,:,11) = 1 y(:,:,12) = 1 y(:,:,13) = 1 y(:,:,14) = 1 y(:,:,15) = 1 y(:,:,16) = 1 y(:,:,17) = 1 y(:,:,18) = 1 y(:,:,1) = 1 y(:,:,2) = 1 y(:,:,3) = 1 y(:,:,4) = 1 y(:,:,5) = 1 y(:,:,6) = 1 y(:,:,7) = 1 y(:,:,8) = 1 y(:,:,9) = 1 y(:,:,10) = 1 y(:,:,11) = 1 y(:,:,12) = 1 y(:,:,13) = 1 y(:,:,14) = 1 y(:,:,15) = 1 y(:,:,16) = 1 y(:,:,17) = 1 y(:,:,18) = 1 y(:,:,19) = 1 y(:,:,1) = 1 y(:,:,2) = 1 y(:,:,3) = 1 y(:,:,4) = 1 y(:,:,5) = 1 y(:,:,6) = 1 y(:,:,7) = 1 y(:,:,8) = 1 y(:,:,9) = 1 y(:,:,10) = 1 y(:,:,11) = 1 y(:,:,12) = 1 y(:,:,13) = 1 y(:,:,14) = 1 y(:,:,15) = 1 y(:,:,16) = 1 y(:,:,17) = 1 y(:,:,18) = 1 y(:,:,19) = 1 y(:,:,20) = 1 y(:,:,1) = 1 y(:,:,2) = 1 y(:,:,3) = 1 y(:,:,4) = 1 y(:,:,5) = 1 y(:,:,6) = 1 y(:,:,7) = 1 y(:,:,8) = 1 y(:,:,9) = 1 y(:,:,10) = 1 y(:,:,11) = 1 y(:,:,12) = 1 y(:,:,13) = 1 y(:,:,14) = 1 y(:,:,15) = 1 y(:,:,16) = 1 y(:,:,17) = 1 y(:,:,18) = 1 y(:,:,19) = 1 y(:,:,20) = 1 y(:,:,21) = 1 y(:,:,1) = 1 y(:,:,2) = 1 y(:,:,3) = 1 y(:,:,4) = 1 y(:,:,5) = 1 y(:,:,6) = 1 y(:,:,7) = 1 y(:,:,8) = 1 y(:,:,9) = 1 y(:,:,10) = 1 y(:,:,11) = 1 y(:,:,12) = 1 y(:,:,13) = 1 y(:,:,14) = 1 y(:,:,15) = 1 y(:,:,16) = 1 y(:,:,17) = 1 y(:,:,18) = 1 y(:,:,19) = 1 y(:,:,20) = 1 y(:,:,21) = 1 y(:,:,22) = 1 y(:,:,1) = 1 y(:,:,2) = 1 y(:,:,3) = 1 y(:,:,4) = 1 y(:,:,5) = 1 y(:,:,6) = 1 y(:,:,7) = 1 y(:,:,8) = 1 y(:,:,9) = 1 y(:,:,10) = 1 y(:,:,11) = 1 y(:,:,12) = 1 y(:,:,13) = 1 y(:,:,14) = 1 y(:,:,15) = 1 y(:,:,16) = 1 y(:,:,17) = 1 y(:,:,18) = 1 y(:,:,19) = 1 y(:,:,20) = 1 y(:,:,21) = 1 y(:,:,22) = 1 y(:,:,23) = 1 y(:,:,1) = 1 y(:,:,2) = 1 y(:,:,3) = 1 y(:,:,4) = 1 y(:,:,5) = 1 y(:,:,6) = 1 y(:,:,7) = 1 y(:,:,8) = 1 y(:,:,9) = 1 y(:,:,10) = 1 y(:,:,11) = 1 y(:,:,12) = 1 y(:,:,13) = 1 y(:,:,14) = 1 y(:,:,15) = 1 y(:,:,16) = 1 y(:,:,17) = 1 y(:,:,18) = 1 y(:,:,19) = 1 y(:,:,20) = 1 y(:,:,21) = 1 y(:,:,22) = 1 y(:,:,23) = 1 y(:,:,24) = 1 y(:,:,1) = 1 y(:,:,2) = 1 y(:,:,3) = 1 y(:,:,4) = 1 y(:,:,5) = 1 y(:,:,6) = 1 y(:,:,7) = 1 y(:,:,8) = 1 y(:,:,9) = 1 y(:,:,10) = 1 y(:,:,11) = 1 y(:,:,12) = 1 y(:,:,13) = 1 y(:,:,14) = 1 y(:,:,15) = 1 y(:,:,16) = 1 y(:,:,17) = 1 y(:,:,18) = 1 y(:,:,19) = 1 y(:,:,20) = 1 y(:,:,21) = 1 y(:,:,22) = 1 y(:,:,23) = 1 y(:,:,24) = 1 y(:,:,25) = 1 y(:,:,1) = 1 y(:,:,2) = 1 y(:,:,3) = 1 y(:,:,4) = 1 y(:,:,5) = 1 y(:,:,6) = 1 y(:,:,7) = 1 y(:,:,8) = 1 y(:,:,9) = 1 y(:,:,10) = 1 y(:,:,11) = 1 y(:,:,12) = 1 y(:,:,13) = 1 y(:,:,14) = 1 y(:,:,15) = 1 y(:,:,16) = 1 y(:,:,17) = 1 y(:,:,18) = 1 y(:,:,19) = 1 y(:,:,20) = 1 y(:,:,21) = 1 y(:,:,22) = 1 y(:,:,23) = 1 y(:,:,24) = 1 y(:,:,25) = 1 y(:,:,26) = 1 y(:,:,1) = 1 y(:,:,2) = 1 y(:,:,3) = 1 y(:,:,4) = 1 y(:,:,5) = 1 y(:,:,6) = 1 y(:,:,7) = 1 y(:,:,8) = 1 y(:,:,9) = 1 y(:,:,10) = 1 y(:,:,11) = 1 y(:,:,12) = 1 y(:,:,13) = 1 y(:,:,14) = 1 y(:,:,15) = 1 y(:,:,16) = 1 y(:,:,17) = 1 y(:,:,18) = 1 y(:,:,19) = 1 y(:,:,20) = 1 y(:,:,21) = 1 y(:,:,22) = 1 y(:,:,23) = 1 y(:,:,24) = 1 y(:,:,25) = 1 y(:,:,26) = 1 y(:,:,27) = 1 y(:,:,1) = 1 y(:,:,2) = 1 y(:,:,3) = 1 y(:,:,4) = 1 y(:,:,5) = 1 y(:,:,6) = 1 y(:,:,7) = 1 y(:,:,8) = 1 y(:,:,9) = 1 y(:,:,10) = 1 y(:,:,11) = 1 y(:,:,12) = 1 y(:,:,13) = 1 y(:,:,14) = 1 y(:,:,15) = 1 y(:,:,16) = 1 y(:,:,17) = 1 y(:,:,18) = 1 y(:,:,19) = 1 y(:,:,20) = 1 y(:,:,21) = 1 y(:,:,22) = 1 y(:,:,23) = 1 y(:,:,24) = 1 y(:,:,25) = 1 y(:,:,26) = 1 y(:,:,27) = 1 y(:,:,28) = 1 y(:,:,1) = 1 y(:,:,2) = 1 y(:,:,3) = 1 y(:,:,4) = 1 y(:,:,5) = 1 y(:,:,6) = 1 y(:,:,7) = 1 y(:,:,8) = 1 y(:,:,9) = 1 y(:,:,10) = 1 y(:,:,11) = 1 y(:,:,12) = 1 y(:,:,13) = 1 y(:,:,14) = 1 y(:,:,15) = 1 y(:,:,16) = 1 y(:,:,17) = 1 y(:,:,18) = 1 y(:,:,19) = 1 y(:,:,20) = 1 y(:,:,21) = 1 y(:,:,22) = 1 y(:,:,23) = 1 y(:,:,24) = 1 y(:,:,25) = 1 y(:,:,26) = 1 y(:,:,27) = 1 y(:,:,28) = 1 y(:,:,29) = 1 y(:,:,1) = 1 y(:,:,2) = 1 y(:,:,3) = 1 y(:,:,4) = 1 y(:,:,5) = 1 y(:,:,6) = 1 y(:,:,7) = 1 y(:,:,8) = 1 y(:,:,9) = 1 y(:,:,10) = 1 y(:,:,11) = 1 y(:,:,12) = 1 y(:,:,13) = 1 y(:,:,14) = 1 y(:,:,15) = 1 y(:,:,16) = 1 y(:,:,17) = 1 y(:,:,18) = 1 y(:,:,19) = 1 y(:,:,20) = 1 y(:,:,21) = 1 y(:,:,22) = 1 y(:,:,23) = 1 y(:,:,24) = 1 y(:,:,25) = 1 y(:,:,26) = 1 y(:,:,27) = 1 y(:,:,28) = 1 y(:,:,29) = 1 y(:,:,30) = 1 y(:,:,1) = ...

Assertion failed.

3   Fail
x=eye(7);r=2;c=2; M=BreakTheMatrix(x,r,c); ids=[1 8 15 22 29 36]; urs=ids(1:5)+1; lls=urs+5; z=setxor(1:size(M,3),[ids urs lls]); a1=arrayfun(@(a) isequal(M(:,:,a),eye(2)),ids); a2=arrayfun(@(a) isequal(M(:,:,a),[0 1 ; 0 0]),urs); a3=arrayfun(@(a) isequal(M(:,:,a),[0 0 ; 1 0]),lls); a4=arrayfun(@(a) isequal(M(:,:,a),zeros(2)),z); assert(all([a1 a2 a3 a4]))

y = 1 0 0 1 y(:,:,1) = 1 0 0 1 y(:,:,2) = 1 0 0 1 y(:,:,1) = 1 0 0 1 y(:,:,2) = 1 0 0 1 y(:,:,3) = 1 0 0 1 y(:,:,1) = 1 0 0 1 y(:,:,2) = 1 0 0 1 y(:,:,3) = 1 0 0 1 y(:,:,4) = 1 0 0 1

Index in position 3 exceeds array bounds (must not exceed 4). Error in Test3>@(a)isequal(M(:,:,a),eye(2)) (line 7) a1=arrayfun(@(a) isequal(M(:,:,a),eye(2)),ids); Error in Test3 (line 7) a1=arrayfun(@(a) isequal(M(:,:,a),eye(2)),ids);

4   Pass
u=ceil(10*rand())+4; x=magic(u);r=u;c=u; M=BreakTheMatrix(x,r,c); assert(isequal(M,x))

y = 68 81 94 107 120 1 14 27 40 53 66 80 93 106 119 11 13 26 39 52 65 67 92 105 118 10 12 25 38 51 64 77 79 104 117 9 22 24 37 50 63 76 78 91 116 8 21 23 36 49 62 75 88 90 103 7 20 33 35 48 61 74 87 89 102 115 19 32 34 47 60 73 86 99 101 114 6 31 44 46 59 72 85 98 100 113 5 18 43 45 58 71 84 97 110 112 4 17 30 55 57 70 83 96 109 111 3 16 29 42 56 69 82 95 108 121 2 15 28 41 54

5   Fail
temp=ceil(8*rand)+3; x=ones(temp);r=2;c=2; M=BreakTheMatrix(x,r,c); assert(size(M,3)==(temp-1)^2); assert(all(arrayfun(@(a) isequal(M(:,:,a),ones(2)),1:size(M,3))))

y = 1 1 1 1 y(:,:,1) = 1 1 1 1 y(:,:,2) = 1 1 1 1

Assertion failed.

6   Pass
x=eye(7);r=7;c=7; assert(isequal(x,BreakTheMatrix(x,r,c)))

y = 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1