Cody

# Problem 1167. matrix zigzag

Solution 2109714

Submitted on 29 Jan 2020 by xr hu
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
x = [1 2; 3 4]; y_correct = [1 2 3 4]; assert(isequal(zigzag(x),y_correct))

h = 2 3 4 s = [] s = 1 s = 1 2 3 s = 1 2 3 4

2   Pass
x = [ 1 2 3; 4 5 6; 7 8 9]; y_correct = [ 1 2 4 7 5 3 6 8 9]; assert(isequal(zigzag(x),y_correct))

h = 2 3 4 5 6 s = [] s = 1 s = 1 2 4 s = 1 2 4 7 5 3 s = 1 2 4 7 5 3 6 8 s = 1 2 4 7 5 3 6 8 9

3   Pass
x = magic(4); y_correct = [16 2 5 9 11 3 13 10 7 4 14 6 8 12 15 1]; assert(isequal(zigzag(x),y_correct))

h = 2 3 4 5 6 7 8 s = [] s = 16 s = 16 2 5 s = 16 2 5 9 11 3 s = 16 2 5 9 11 3 13 10 7 4 s = 16 2 5 9 11 3 13 10 7 4 14 6 8 s = 16 2 5 9 11 3 13 10 7 4 14 6 8 12 15 s = 16 2 5 9 11 3 13 10 7 4 14 6 8 12 15 1

### Community Treasure Hunt

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

Start Hunting!