Cody

# Problem 44350. Breaking Out of the Matrix

Solution 1306249

Submitted on 20 Oct 2017 by Eric G.
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
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) = 2 5 8 3 6 9 y(:,:,1) = 1 4 7 2 5 8 y(:,:,2) = 2 5 8 3 6 9 y(:,:,3) = 4 7 10 5 8 11 y(:,:,1) = 1 4 7 2 5 8 y(:,:,2) = 2 5 8 3 6 9 y(:,:,3) = 4 7 10 5 8 11 y(:,:,4) = 5 8 11 6 9 12

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

3   Pass
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) = 0 1 0 0 y(:,:,1) = 1 0 0 1 y(:,:,2) = 0 1 0 0 y(:,:,3) = 0 0 0 0 y(:,:,1) = 1 0 0 1 y(:,:,2) = 0 1 0 0 y(:,:,3) = 0 0 0 0 y(:,:,4) = 0 0 0 0 y(:,:,1) = 1 0 0 1 y(:,:,2) = 0 1 0 0 y(:,:,3) = 0 0 0 0 y(:,:,4) = 0 0 0 0 y(:,:,5) = 0 0 0 0 y(:,:,1) = 1 0 0 1 y(:,:,2) = 0 1 0 0 y(:,:,3) = 0 0 0 0 y(:,:,4) = 0 0 0 0 y(:,:,5) = 0 0 0 0 y(:,:,6) = 0 0 0 0 y(:,:,1) = 1 0 0 1 y(:,:,2) = 0 1 0 0 y(:,:,3) = 0 0 0 0 y(:,:,4) = 0 0 0 0 y(:,:,5) = 0 0 0 0 y(:,:,6) = 0 0 0 0 y(:,:,7) = 0 0 1 0 y(:,:,1) = 1 0 0 1 y(:,:,2) = 0 1 0 0 y(:,:,3) = 0 0 0 0 y(:,:,4) = 0 0 0 0 y(:,:,5) = 0 0 0 0 y(:,:,6) = 0 0 0 0 y(:,:,7) = 0 0 1 0 y(:,:,8) = 1 0 0 1 y(:,:,1) = 1 0 0 1 y(:,:,2) = 0 1 0 0 y(:,:,3) = 0 0 0 0 y(:,:,4) = 0 0 0 0 y(:,:,5) = 0 0 0 0 y(:,:,6)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:,:,3) = 0 0 0 0 y(:,:,4) = 0 0 0 0 y(:,:,5) = 0 0 0 0 y(:,:,6) = 0 0 0 0 y(:,:,7) = 0 0 1 0 y(:,:,8) = 1 0 0 1 y(:,:,9) = 0 1 0 0 y(:,:,10) = 0 0 0 0 y(:,:,11) = 0 0 0 0 y(:,:,12) = 0 0 0 0 y(:,:,13) = 0 0 0 0 y(:,:,14) = 0 0 1 0 y(:,:,15) = 1 0 0 1 y(:,:,16) = 0 1 0 0 y(:,:,17) = 0 0 0 0 y(:,:,18) = 0 0 0 0 y(:,:,19) = 0 0 0 0 y(:,:,20) = 0 0 0 0 y(:,:,21) = 0 0 1 0 y(:,:,1) = 1 0 0 1 y(:,:,2) = 0 1 0 0 y(:,:,3) = 0 0 0 0 y(:,:,4) = 0 0 0 0 y(:,:,5) = 0 0 0 0 y(:,:,6) = 0 0 0 0 y(:,:,7) = 0 0 1 0 y(:,:,8) = 1 0 0 1 y(:,:,9) = 0 1 0 0 y(:,:,10) = 0 0 0 0 y(:,:,11) = 0 0 0 0 y(:,:,12) = 0 0 0 0 y(:,:,13) = 0 0 0 0 y(:,:,14) = 0 0 1 0 y(:,:,15) = 1 0 0 1 y(:,:,16) = 0 1 0 0 y(:,:,17) = 0 0 0 0 y...

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

y = 17 24 1 8 15 23 5 7 14 16 4 6 13 20 22 10 12 19 21 3 11 18 25 2 9

### Community Treasure Hunt

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

Start Hunting!