Cody

Problem 45399. ZigZag - 01

Solution 3447213

Submitted on 28 Oct 2020 by Irina Anjum Pranti
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 = magic(4); y=[16 2 3 13 10 7 4 14 15 1]; assert(isequal(z_mat(a),y))

b = 4 4 m = 4 c = [] j = 3 c = 10 j = 2 c = 10 7 j = 1 y = 16 2 3 13 10 7 4 14 15 1

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

b = 77 77 m = 77 c = [] j = 76 c = 1 j = 75 c = 1 1 j = 74 c = 1 1 1 j = 73 c = 1 1 1 1 j = 72 c = 1 1 1 1 1 j = 71 c = 1 1 1 1 1 1 j = 70 c = 1 1 1 1 1 1 1 j = 69 c = 1 1 1 1 1 1 1 1 j = 68 c = 1 1 1 1 1 1 1 1 1 j = 67 c = 1 1 1 1 1 1 1 1 1 1 j = 66 c = 1 1 1 1 1 1 1 1 1 1 1 j = 65 c = 1 1 1 1 1 1 1 1 1 1 1 1 j = 64 c = 1 1 1 1 1 1 1 1 1 1 1 1 1 j = 63 c = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 j = 62 c = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 j = 61 c = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 j = 60 c = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 j = 59 c = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 j = 58 c = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 j = 57 c = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 j = 56 c = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 j = 55 c = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 j = 54 c = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 j = 53 c = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 j = 52 c = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 j = 51 c = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 j = 50 c = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 j = 49 c = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 j = 48 c = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 j = 47 c = Columns 1 through 29 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Column 30 1 j = 46 c = Columns 1 through 29 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Columns 30 through 31 1 1 j = 45 c = Columns 1 through 29 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Columns 30 through 32 1 1 1 j = 44 c = Columns 1 through 29 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Columns 30 through 33 1 1 1 1 j = 43 c = Columns 1 through 29 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Columns 30 through 34 1 1 1 1 1 j = 42 c = Columns 1 through 29 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Columns 30 through 35 1 1 1 1 1 1 j = 41 c = Columns 1 through 29 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Columns 30 through 36 1 1 1 1 1 1 1 j = 40 c = Columns 1 through 29 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Columns 30 through 37 1 1 1 1 1 1 1 1 j = 39 c = Columns 1 through 29 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Columns 30 through 38 1 1 1 1 1 1 1 1 1 j = 38 c = Columns 1 through 29 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Columns 30 through 39 1 1 1 1 1 1 1 1 1 1 j = 37 c = Columns 1 through 29 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Columns 30 through 40 1 1 1 1 1 1 1 1 1 1 1 j = 36 c = Columns 1 through 29 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Columns 30 through 41 1 1 1 1 1 1 1 1 1 1 1 1 j = 35 c = Columns 1 through 29 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Columns 30 through 42 1 1 1 1 1 1 1 1 1 1 1 1 1 j = 34 c = Columns 1 through 29 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Columns 30 through 43 1 1 1 1 1 1 1 1 1 1 1 1 1 1 j = 33 c = Columns 1 through 29 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Columns 30 through 44 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 j = 32 c = Columns 1 through 29 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Columns 30 through 45 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 j = 31 c = Columns 1 through 29 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Columns 30 through 46 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 j = 30 c = Columns 1 through 29 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Columns 30 through 47 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 j = 29 c = Columns 1 through 29 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Columns 30 through 48 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 j = 28 c = Columns 1 through 29 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Columns 30 through 49 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 j = 27 c = Columns 1 through 29 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Columns 30 through 50 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 j = 26 c = Columns 1 through 29 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

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

b = 7 7 m = 7 c = [] j = 6 c = 0 j = 5 c = 0 0 j = 4 c = 0 0 1 j = 3 c = 0 0 1 0 j = 2 c = 0 0 1 0 0 j = 1 y = 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1

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

b = 4 4 m = 4 c = [] j = 3 c = 3 j = 2 c = 3 3 j = 1 y = 32 1 3 3 3 3 0 654 2 1

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

b = 2 2 m = 2 c = [] j = 1 y = 101 101 101 101

Suggested Problems

More from this Author149

Community Treasure Hunt

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

Start Hunting!