Cody

# Problem 45399. ZigZag - 01

Solution 2182079

Submitted on 30 Mar 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
a = magic(4); y=[16 2 3 13 10 7 4 14 15 1]; assert(isequal(z_mat(a),y))

Index in position 1 exceeds array bounds (must not exceed 4). Error in z_mat (line 3) ye=a(end+1,1):a(end,end); Error in Test1 (line 3) assert(isequal(z_mat(a),y))

2   Fail
a = ones(77); y=ones(1,229); assert(isequal(z_mat(a),y))

Index in position 1 exceeds array bounds (must not exceed 77). Error in z_mat (line 3) ye=a(end+1,1):a(end,end); Error in Test2 (line 3) assert(isequal(z_mat(a),y))

3   Fail
a = eye(7); y=[1,zeros(1,8),1,zeros(1,8),1]; assert(isequal(z_mat(a),y))

Index in position 1 exceeds array bounds (must not exceed 7). Error in z_mat (line 3) ye=a(end+1,1):a(end,end); Error in Test3 (line 3) assert(isequal(z_mat(a),y))

4   Fail
a=[32 1 3 3;3 3 3 3;56 3 54 344;0 654 2 1]; y=[32 1 3 3 3 3 0 654 2 1]; assert(isequal(z_mat(a),y))

Index in position 1 exceeds array bounds (must not exceed 4). Error in z_mat (line 3) ye=a(end+1,1):a(end,end); Error in Test4 (line 3) assert(isequal(z_mat(a),y))

5   Fail
a = [101 101;101 101]; assert(isequal(z_mat(a),a(:)'))

Index in position 1 exceeds array bounds (must not exceed 2). Error in z_mat (line 3) ye=a(end+1,1):a(end,end); Error in Test5 (line 2) assert(isequal(z_mat(a),a(:)'))

### Community Treasure Hunt

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

Start Hunting!