Cody

# Problem 1167. matrix zigzag

Solution 2878640

Submitted on 26 Aug 2020 by mohsen
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))

c = 1 y = 1×1 cell array {[1]} c = 2 y = 1×2 cell array {[1]} {1×2 double} y = 1×3 cell array {[1]} {1×2 double} {[4]} c = 4 y = 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))

c = 1 y = 1×1 cell array {[1]} c = 2 y = 1×2 cell array {[1]} {1×2 double} c = 3 d = 3 5 7 d2 = 7 5 3 y = 1×3 cell array {[1]} {1×2 double} {1×3 double} y = 1×4 cell array {[1]} {1×2 double} {1×3 double} {1×2 double} c = 5 y = 1×5 cell array {[1]} {1×2 double} {1×3 double} {1×2 double} {[9]} c = 6 y = 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))

c = 1 y = 1×1 cell array {[16]} c = 2 y = 1×2 cell array {[16]} {1×2 double} c = 3 d = 3 11 9 d2 = 9 11 3 y = 1×3 cell array {[16]} {1×2 double} {1×3 double} c = 4 y = 1×4 cell array {[16]} {1×2 double} {1×3 double} {1×4 double} d = 8 6 14 d2 = 14 6 8 y = 1×5 cell array {[16]} {1×2 double} {1×3 double} {1×4 double} {1×3 double} c = 6 y = 1×6 cell array {[16]} {1×2 double} {1×3 double} {1×4 double} {1×3 double} {1×2 double} c = 7 y = 1×7 cell array {[16]} {1×2 double} {1×3 double} {1×4 double} {1×3 double} {1×2 double} {[1]} c = 8 y = 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!