Cody

# Problem 45401. ZigZag - 02

Solution 3035452

Submitted on 2 Oct 2020 by Alfonso Nieto-Castanon
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))

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

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

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

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

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

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

### Community Treasure Hunt

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

Start Hunting!