Cody

# Problem 45401. ZigZag - 02

Solution 2185389

Submitted on 31 Mar 2020 by Nikolaos Nikolaou
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
a=[1,2,3,4,5; 6,7,8,9,1; 1,1,1,1,1]; y=[1,2,3,4,5,8,1,1,1,1,1]; assert(isequal(z_mat_02(a),y))

t = 3 5 y = 1 2 3 4 5 8 1 1 1 1 1

2   Pass
a=reshape(1:24,3,[]); y=[1:3:22,3:3:24]; assert(isequal(z_mat_02(a),y))

t = 3 8 y = 1 4 7 10 13 16 19 22 11 3 6 9 12 15 18 21 24 y = 1 4 7 10 13 16 19 22 3 6 9 12 15 18 21 24

3   Pass
a=reshape(1:24,4,[]); y=[1:4:21,4:4:24]; assert(isequal(z_mat_02(a),y))

t = 4 6 y = 1 5 9 13 17 21 4 8 12 16 20 24

4   Pass
a=reshape(30:65,12,[]) y=[ 30 42 54 41 53 65]; assert(isequal(z_mat_02(a),y))

a = 30 42 54 31 43 55 32 44 56 33 45 57 34 46 58 35 47 59 36 48 60 37 49 61 38 50 62 39 51 63 40 52 64 41 53 65 t = 12 3 y = 30 42 54 41 53 65

5   Pass
a=magic(5); y=[ 17 24 1 8 15 14 13 12 11 18 25 2 9]; assert(isequal(z_mat_02(a),y))

t = 5 5 t1 = 17 24 1 8 15 t2 = 15 14 13 12 11 t3 = 11 18 25 2 9 t3 = 18 25 2 9 y = 17 24 1 8 15 14 13 12 11 18 25 2 9

6   Pass
a=reshape(magic(9),3,[]); y=[47 77 26 58 7 28 69 18 39 80 20 50 1 31 61 12 42 72 23 53 74 34 55 4 45 66 15 41 67 16 37 78 27 48 8 29 59 10 40 70 21 51 81 32 62 2 43 64 13 54 75 24 56 5 35]; assert(isequal(z_mat_02(a),y))

t = 3 27 y = Columns 1 through 29 47 77 26 58 7 28 69 18 39 80 20 50 1 31 61 12 42 72 23 53 74 34 55 4 45 66 15 41 67 Columns 30 through 55 16 37 78 27 48 8 29 59 10 40 70 21 51 81 32 62 2 43 64 13 54 75 24 56 5 35

7   Pass
a=eye(5); aa=[a;a;a]; y=[ 1 0 0 0 0 1 0 0 0 0 1]; assert(isequal(z_mat_02(aa),y))

t = 15 5 y = 1 0 0 0 0 1 0 0 0 0 1

### Community Treasure Hunt

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

Start Hunting!