Cody

Solution 1057889

Submitted on 21 Nov 2016 by Jaeho Seol
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 = 0; z_correct = 1; assert(isequal(lastzerorow(a),z_correct))

z = 1

2   Pass
a = 1; z_correct = 0; assert(isequal(lastzerorow(a),z_correct))

3   Pass
a = randi(1000,1000,1); z_correct = 0; assert(isequal(lastzerorow(a),z_correct))

4   Pass
a = [0;1;0;2;0;3;0;4;0;5;0;6;0;7;0;8;0;9;0;10]; z_correct = 19; assert(isequal(lastzerorow(a),z_correct))

z = 19

5   Pass
n = randi(1000); a = tril(ones(n)); z_correct = 0:n-1; assert(isequal(lastzerorow(a),z_correct))

z = 0 1 z = 0 1 2 z = 0 1 2 3 z = 0 1 2 3 4 z = 0 1 2 3 4 5 z = 0 1 2 3 4 5 6 z = 0 1 2 3 4 5 6 7 z = 0 1 2 3 4 5 6 7 8 z = 0 1 2 3 4 5 6 7 8 9 z = 0 1 2 3 4 5 6 7 8 9 10 z = 0 1 2 3 4 5 6 7 8 9 10 11 z = 0 1 2 3 4 5 6 7 8 9 10 11 12 z = 0 1 2 3 4 5 6 7 8 9 10 11 12 13 z = 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 z = 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 z = Columns 1 through 16 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Column 17 16 z = Columns 1 through 16 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Columns 17 through 18 16 17 z = Columns 1 through 16 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Columns 17 through 19 16 17 18 z = Columns 1 through 16 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Columns 17 through 20 16 17 18 19 z = Columns 1 through 16 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Columns 17 through 21 16 17 18 19 20 z = Columns 1 through 16 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Columns 17 through 22 16 17 18 19 20 21 z = Columns 1 through 16 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Columns 17 through 23 16 17 18 19 20 21 22 z = Columns 1 through 16 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Columns 17 through 24 16 17 18 19 20 21 22 23 z = Columns 1 through 16 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Columns 17 through 25 16 17 18 19 20 21 22 23 24 z = Columns 1 through 16 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Columns 17 through 26 16 17 18 19 20 21 22 23 24 25 z = Columns 1 through 16 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Columns 17 through 27 16 17 18 19 20 21 22 23 24 25 26 z = Columns 1 through 16 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Columns 17 through 28 16 17 18 19 20 21 22 23 24 25 26 27 z = Columns 1 through 16 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Columns 17 through 29 16 17 18 19 20 21 22 23 24 25 26 27 28 z = Columns 1 through 16 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Columns 17 through 30 16 17 18 19 20 21 22 23 24 25 26 27 28 29 z = Columns 1 through 16 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Columns 17 through 31 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 z = Columns 1 through 16 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Columns 17 through 32 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 z = Columns 1 through 16 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Columns 17 through 32 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 Column 33 32 z = Columns 1 through 16 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Columns 17 through 32 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 Columns 33 through 34 32 33 z = Columns 1 through 16 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Columns 17 through 32 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 Columns 33 through 35 32 33 34 z = Columns 1 through 16 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Columns 17 through 32 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 Columns 33 through 36 32 33 34 35 z = Columns 1 through 16 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Columns 17 through 32 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 Columns 33 through 37 32 33 34 35 36 z = Columns 1 through 16 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Columns 17 through 32 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 Columns 33 through 38 32 33 34 35 36 37 z = Columns 1 through 16 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Columns 17 through 32 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 Columns 33 through 39 32 33 34 35 36 37 38 z = Columns 1 through 16 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Columns 17 through 32 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 Columns 33 through 40 32 33 34 35 36 37 38 39 z = Columns 1 through 16 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Columns 17 through 32 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 Columns 33 through 41 32 33 34 35 36 37 38 39 40 z = Columns 1 through 16 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Columns 17 through 32 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 Columns 33 through 42 32 33 34 35 36 37 38 39 40 41 z = Columns 1 through 16 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Columns 17 through 32 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 Columns 33 through 43 32 33 34 35 36 37 38 39 40 41 42 z = Columns 1 through 16 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Columns 17 through 32 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 Columns 33 through 44 32 33 34 35 36 37 38 39 40 41 42 43 z = Columns 1 through 16 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Columns 17 through 32 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 Columns 33 through 45 32 33 34 35 36 37 38 39 40 41 42 43 44 z = Columns 1 through 16 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Columns 17 through 32 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 Columns 33 through 46 32 33 34 35 36 37 38 39 40 41 42 43 44 45 z = Columns 1 through 16 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Columns 17 through 32 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 Columns 33 through 47 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 z = Columns 1 through 16 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Columns 17 through 32 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 Columns 33 through 48 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 z = Columns 1 through 16 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Columns 17 through 32 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 Columns 33 through 48 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 Column 49 48 z = Columns 1 through 16 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Columns 17...

6   Pass
n = randi(1000); a = tril(ones(n),-1); z_correct = 1:n; assert(isequal(lastzerorow(a),z_correct))

z = 1 z = 1 2 z = 1 2 3 z = 1 2 3 4 z = 1 2 3 4 5 z = 1 2 3 4 5 6 z = 1 2 3 4 5 6 7 z = 1 2 3 4 5 6 7 8 z = 1 2 3 4 5 6 7 8 9 z = 1 2 3 4 5 6 7 8 9 10 z = 1 2 3 4 5 6 7 8 9 10 11 z = 1 2 3 4 5 6 7 8 9 10 11 12 z = 1 2 3 4 5 6 7 8 9 10 11 12 13 z = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 z = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 z = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 z = Columns 1 through 16 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 Column 17 17 z = Columns 1 through 16 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 Columns 17 through 18 17 18 z = Columns 1 through 16 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 Columns 17 through 19 17 18 19 z = Columns 1 through 16 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 Columns 17 through 20 17 18 19 20 z = Columns 1 through 16 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 Columns 17 through 21 17 18 19 20 21 z = Columns 1 through 16 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 Columns 17 through 22 17 18 19 20 21 22 z = Columns 1 through 16 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 Columns 17 through 23 17 18 19 20 21 22 23 z = Columns 1 through 16 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 Columns 17 through 24 17 18 19 20 21 22 23 24 z = Columns 1 through 16 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 Columns 17 through 25 17 18 19 20 21 22 23 24 25 z = Columns 1 through 16 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 Columns 17 through 26 17 18 19 20 21 22 23 24 25 26 z = Columns 1 through 16 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 Columns 17 through 27 17 18 19 20 21 22 23 24 25 26 27 z = Columns 1 through 16 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 Columns 17 through 28 17 18 19 20 21 22 23 24 25 26 27 28 z = Columns 1 through 16 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 Columns 17 through 29 17 18 19 20 21 22 23 24 25 26 27 28 29 z = Columns 1 through 16 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 Columns 17 through 30 17 18 19 20 21 22 23 24 25 26 27 28 29 30 z = Columns 1 through 16 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 Columns 17 through 31 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 z = Columns 1 through 16 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 Columns 17 through 32 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 z = Columns 1 through 16 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 Columns 17 through 32 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 Column 33 33 z = Columns 1 through 16 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 Columns 17 through 32 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 Columns 33 through 34 33 34 z = Columns 1 through 16 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 Columns 17 through 32 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 Columns 33 through 35 33 34 35 z = Columns 1 through 16 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 Columns 17 through 32 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 Columns 33 through 36 33 34 35 36 z = Columns 1 through 16 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 Columns 17 through 32 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 Columns 33 through 37 33 34 35 36 37 z = Columns 1 through 16 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 Columns 17 through 32 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 Columns 33 through 38 33 34 35 36 37 38 z = Columns 1 through 16 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 Columns 17 through 32 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 Columns 33 through 39 33 34 35 36 37 38 39 z = Columns 1 through 16 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 Columns 17 through 32 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 Columns 33 through 40 33 34 35 36 37 38 39 40 z = Columns 1 through 16 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 Columns 17 through 32 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 Columns 33 through 41 33 34 35 36 37 38 39 40 41 z = Columns 1 through 16 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 Columns 17 through 32 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 Columns 33 through 42 33 34 35 36 37 38 39 40 41 42 z = Columns 1 through 16 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 Columns 17 through 32 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 Columns 33 through 43 33 34 35 36 37 38 39 40 41 42 43 z = Columns 1 through 16 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 Columns 17 through 32 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 Columns 33 through 44 33 34 35 36 37 38 39 40 41 42 43 44 z = Columns 1 through 16 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 Columns 17 through 32 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 Columns 33 through 45 33 34 35 36 37 38 39 40 41 42 43 44 45 z = Columns 1 through 16 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 Columns 17 through 32 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 Columns 33 through 46 33 34 35 36 37 38 39 40 41 42 43 44 45 46 z = Columns 1 through 16 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 Columns 17 through 32 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 Columns 33 through 47 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 z = Columns 1 through 16 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 Columns 17 through 32 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 Columns 33 through 48 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 z = Columns 1 through 16 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 Columns 17 through 32 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 Columns 33 through 48 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 Column 49 49 z = Columns 1 through 16 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16...

7   Pass
n = randi(1000); d = randi(n-1); a = tril(ones(n),-d); z_correct = min((0:n-1)+d,n); assert(isequal(lastzerorow(a),z_correct))

z = 77 z = 77 78 z = 77 78 79 z = 77 78 79 80 z = 77 78 79 80 81 z = 77 78 79 80 81 82 z = 77 78 79 80 81 82 83 z = 77 78 79 80 81 82 83 84 z = 77 78 79 80 81 82 83 84 85 z = 77 78 79 80 81 82 83 84 85 86 z = 77 78 79 80 81 82 83 84 85 86 87 z = 77 78 79 80 81 82 83 84 85 86 87 88 z = 77 78 79 80 81 82 83 84 85 86 87 88 89 z = 77 78 79 80 81 82 83 84 85 86 87 88 89 90 z = 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 z = 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 z = Columns 1 through 16 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 Column 17 93 z = Columns 1 through 16 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 Columns 17 through 18 93 94 z = Columns 1 through 16 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 Columns 17 through 19 93 94 95 z = Columns 1 through 16 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 Columns 17 through 20 93 94 95 96 z = Columns 1 through 16 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 Columns 17 through 21 93 94 95 96 97 z = Columns 1 through 16 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 Columns 17 through 22 93 94 95 96 97 98 z = Columns 1 through 16 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 Columns 17 through 23 93 94 95 96 97 98 99 z = Columns 1 through 16 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 Columns 17 through 24 93 94 95 96 97 98 99 100 z = Columns 1 through 16 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 Columns 17 through 25 93 94 95 96 97 98 99 100 101 z = Columns 1 through 16 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 Columns 17 through 26 93 94 95 96 97 98 99 100 101 102 z = Columns 1 through 16 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 Columns 17 through 27 93 94 95 96 97 98 99 100 101 102 103 z = Columns 1 through 16 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 Columns 17 through 28 93 94 95 96 97 98 99 100 101 102 103 104 z = Columns 1 through 16 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 Columns 17 through 29 93 94 95 96 97 98 99 100 101 102 103 104 105 z = Columns 1 through 16 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 Columns 17 through 30 93 94 95 96 97 98 99 100 101 102 103 104 105 106 z = Columns 1 through 16 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 Columns 17 through 31 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 z = Columns 1 through 16 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 Columns 17 through 32 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 z = Columns 1 through 16 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 Columns 17 through 32 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 Column 33 109 z = Columns 1 through 16 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 Columns 17 through 32 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 Columns 33 through 34 109 110 z = Columns 1 through 16 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 Columns 17 through 32 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 Columns 33 through 35 109 110 111 z = Columns 1 through 16 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 Columns 17 through 32 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 Columns 33 through 36 109 110 111 112 z = Columns 1 through 16 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 Columns 17 through 32 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 Columns 33 through 37 109 110 111 112 113 z = Columns 1 through 16 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 Columns 17 through 32 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 Columns 33 through 38 109 110 111 112 113 114 z = Columns 1 through 16 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 Columns 17 through 32 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 Columns 33 through 39 109 110 111 112 113 114 115 z = Columns 1 through 16 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 Columns 17 through 32 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 Columns 33 through 40 109 110 111 112 113 114 115 116 z = Columns 1 through 16 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 Columns 17 through 32 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 Columns 33 through 41 109 110 111 112 113 114 115 116 117 z = Columns 1 through 16 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 Columns 17 through 32 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 Columns 33 through 42 109 110 111 112 113 114 115 116 117 118 z = Columns 1 through 16 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 Columns 17 through 32 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 Columns 33 through 43 109 110 111 112 113 114 115 116 117 118 119 z = Columns 1 through 16 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 Columns 17 through 32 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 Columns 33 through 44 109 110 111 112 113 114 115 116 117 118 119 120 z = Columns 1 through 16 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 Columns 17 through 32 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 Columns 33 through 45 109 110 111 112 113 114 115 116 117 118 119 120 121 z = Columns 1 through 16 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 Columns 17 through 32 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 Columns 33 through 46 109 110 111 112 113 114 115 116 117 118 119 120 121 122 z = Columns 1 through 16 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 Columns 17 through 32 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 Columns 33 through 47 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 z = Columns 1 through 16 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 Columns 17 through 32 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 Columns 33 through 48 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 z = Columns 1 through 16 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 Columns 17 through 32 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 Columns 33 through 48 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 Column 49 125 z = Columns 1 through 16 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92...

8   Pass
a = magic(10)-1; z_correct = [0 0 1 0 0 0 0 0 0 0]; assert(isequal(lastzerorow(a),z_correct))

z = 0 0 1

9   Pass
a = [0 0 9 0; 0 0 1 8; 0 0 4 0; 0 0 2 3; 0 6 7 5]; z_correct = [5 4 0 3]; assert(isequal(lastzerorow(a),z_correct))

z = 5 z = 5 4 z = 5 4 0 3

10   Pass
a = [0 0 0 0 -4 0 0 0 0; 0 0 0 -3 -3 -3 0 0 0; 0 0 -2 3 -2 2 2 0 0; 0 -1 2 -1 1 -1 -1 1 0]; z_correct = [4 3 2 1 0 1 2 3 4]; assert(isequal(lastzerorow(a),z_correct))

z = 4 z = 4 3 z = 4 3 2 z = 4 3 2 1 z = 4 3 2 1 0 1 z = 4 3 2 1 0 1 2 z = 4 3 2 1 0 1 2 3 z = 4 3 2 1 0 1 2 3 4