Cody

# Problem 1699. Find last zero for each column

Solution 1219575

Submitted on 25 Jun 2017 by Augusto Mazzei
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))

f = 1 z = 1

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

f = []

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

f = 0×1 empty double column vector

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

f = 1 3 5 7 9 11 13 15 17 19 z = 19

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

f = 0×1 empty double column vector f = 1 z = 0 1 f = 1 2 z = 0 1 2 f = 1 2 3 z = 0 1 2 3 f = 1 2 3 4 z = 0 1 2 3 4 f = 1 2 3 4 5 z = 0 1 2 3 4 5 f = 1 2 3 4 5 6 z = 0 1 2 3 4 5 6 f = 1 2 3 4 5 6 7 z = 0 1 2 3 4 5 6 7 f = 1 2 3 4 5 6 7 8 z = 0 1 2 3 4 5 6 7 8 f = 1 2 3 4 5 6 7 8 9 z = 0 1 2 3 4 5 6 7 8 9 f = 1 2 3 4 5 6 7 8 9 10 z = 0 1 2 3 4 5 6 7 8 9 10 f = 1 2 3 4 5 6 7 8 9 10 11 z = 0 1 2 3 4 5 6 7 8 9 10 11 f = 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 f = 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 f = 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 f = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 z = 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 f = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 z = 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 f = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 z = 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 f = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 z = 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 f = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 z = 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 f = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 z = 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 f = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 z = 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 f = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 z = 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 f = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 z = 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 f = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 z = 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 f = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 z = 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 f = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 z = 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 f = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 z = 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 f = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 z = 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 f = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 z = Columns 1 through 29 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 Column 30 29 f = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 z = Columns 1 through 29 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 Columns 30 through 31 29 30 f = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 z = Columns 1 through 29 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 Columns 30 through 32 29 30 31 f = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 z = Columns 1 through 29 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 Columns 30 through 33 29 30 31 32 f = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 z = Columns 1 through 29 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 Columns 30 through 34 29 30 31 32 33 f = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 z = Columns 1 through 29 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 Columns 30 through 35 29 30 31 32 33 34 f = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 z = Columns 1 through 29 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 Columns 30 through 36 29 30 31 32 33 34 35 f = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 z = Columns 1 through 29 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 Columns 30 through 37 29 30 31 32 33 34 35 36 f = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 2...

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

f = 1 z = 1 f = 1 2 z = 1 2 f = 1 2 3 z = 1 2 3 f = 1 2 3 4 z = 1 2 3 4 f = 1 2 3 4 5 z = 1 2 3 4 5 f = 1 2 3 4 5 6 z = 1 2 3 4 5 6 f = 1 2 3 4 5 6 7 z = 1 2 3 4 5 6 7 f = 1 2 3 4 5 6 7 8 z = 1 2 3 4 5 6 7 8 f = 1 2 3 4 5 6 7 8 9 z = 1 2 3 4 5 6 7 8 9 f = 1 2 3 4 5 6 7 8 9 10 z = 1 2 3 4 5 6 7 8 9 10 f = 1 2 3 4 5 6 7 8 9 10 11 z = 1 2 3 4 5 6 7 8 9 10 11 f = 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 f = 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 f = 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 f = 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 f = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 z = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 f = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 z = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 f = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 z = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 f = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 z = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 f = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 z = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 f = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 z = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 f = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 z = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 f = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 z = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 f = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 z = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 f = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 z = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 f = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 z = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 f = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 z = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 f = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 z = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 f = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 z = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 f = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 z = Columns 1 through 29 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 Column 30 30 f = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 z = Columns 1 through 29 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 Columns 30 through 31 30 31 f = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 z = Columns 1 through 29 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 Columns 30 through 32 30 31 32 f = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 z = Columns 1 through 29 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 Columns 30 through 33 30 31 32 33 f = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 z = Columns 1 through 29 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 Columns 30 through 34 30 31 32 33 34 f = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 z = Columns 1 through 29 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 Columns 30 through 35 30 31 32 33 34 35 f = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 z = Columns 1 through 29 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 Columns 30 through 36 30 31 32 33 34 35 36 f = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 z = Columns 1 through 29 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27...

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

f = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 z = 24 f = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 z = 24 25 f = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 z = 24 25 26 f = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 z = 24 25 26 27 f = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 z = 24 25 26 27 28 f = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 z = 24 25 26 27 28 29 f = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 z = 24 25 26 27 28 29 30 f = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 z = 24 25 26 27 28 29 30 31 f = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 z = 24 25 26 27 28 29 30 31 32 f = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 z = 24 25 26 27 28 29 30 31 32 33 f = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 z = 24 25 26 27 28 29 30 31 32 33 34 f = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 z = 24 25 26 27 28 29 30 31 32 33 34 35 f = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 z = 24 25 26 27 28 29 30 31 32 33 34 35 36 f = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 z = 24 25 26 27 28 29 30 31 32 33 34 35 36 37 f = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 z = 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 f = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 z = 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 f = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 z = 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 f = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 z = 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 40 f = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 z = 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 40 40 f = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 z = 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 40 40 40 f = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 z = 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 40 40 40 40 f = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 z = 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 40 40 40 40 40 f = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 z = 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 40 40 40 40 40 40 f = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 z = 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 40 40 40 40 40 40 40 f = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 z = 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 40 40 40 40 40 40 40 40 f = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 z = 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 40 40 40 40 40 40 40 40 40 f = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 z = 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 40 40 40 40 40 40 40 40 40 40 f = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 z = 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 40 40 40 40 40 40 40 40 40 40 40 f = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36...

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

f = 0×1 empty double column vector f = 0×1 empty double column vector f = 1 z = 0 0 1 f = 0×1 empty double column vector f = 0×1 empty double column vector f = 0×1 empty double column vector f = 0×1 empty double column vector f = 0×1 empty double column vector f = 0×1 empty double column vector f = 0×1 empty double column vector

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

f = 1 2 3 4 5 z = 5 f = 1 2 3 4 z = 5 4 f = 0×1 empty double column vector f = 1 3 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))

f = 1 2 3 4 z = 4 f = 1 2 3 z = 4 3 f = 1 2 z = 4 3 2 f = 1 z = 4 3 2 1 f = 0×1 empty double column vector f = 1 z = 4 3 2 1 0 1 f = 1 2 z = 4 3 2 1 0 1 2 f = 1 2 3 z = 4 3 2 1 0 1 2 3 f = 1 2 3 4 z = 4 3 2 1 0 1 2 3 4