Problem 44648. Zigzag of square matrix
find zigzag of square matrix in one dimension array a=[1 2 3;4 5 6;7 8 9]; should return b= [1 2 4 7 5 3 6 8 9]
Solution Stats
Problem Comments
-
6 Comments
I guess the assignment should read:
assert(isequal(zigzag(a),y_correct))
While you are amending the Test Suite, please add more test cases (at least four), to ensure only general solutions are successful, not hard-coded submissions. (See Problem 44617 for further ideas.)
Please also check the Solution Template. Currently there is a lot of code in the Solution Template which everyone can see! Usually the Solution Template would be almost blank. —DIV
This problem has been fixed so that it (1) no longer displays a solution in the function template, (2) is solvable, and (3) has additional test cases added.
By the way, this problem is essentially identical to https://www.mathworks.com/matlabcentral/cody/problems/1167-matrix-zigzag.
@goc3: This two problems are not exactly identical, since this problem have a test(the last one) which contains 0 element, this pretty much change everything, if some particular function like nonzeros, etc is considered to be used.
@bainhome: then it's a good thing I added that extra test case to make the problems slightly different.
Solution Comments
Show commentsProblem Recent Solvers18
Suggested Problems
-
Find the longest sequence of 1's in a binary sequence.
6345 Solvers
-
10659 Solvers
-
422 Solvers
-
Getting the indices from a vector
10285 Solvers
-
Generate N equally spaced intervals between -L and L
879 Solvers
More from this Author2
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!