Cody

Problem 1699. Find last zero for each column

Solution 2867222

Submitted on 22 Aug 2020 by VENKATESH VISHNURAM
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))

m = 1 n = 1 z = 1

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

m = 1 n = 1

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

m = 1000 n = 1

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

m = 20 n = 1 z = 19

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

m = 604 n = 604 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 = 0 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 17 z = 0 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 19 z = 0 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 21 z = 0 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 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 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 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 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 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 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 29 z = Columns 1 through 30 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 29 Column 31 30 z = Columns 1 through 30 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 29 Columns 31 through 32 30 31 z = Columns 1 through 30 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 29 Columns 31 through 33 30 31 32 z = Columns 1 through 30 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 29 Columns 31 through 34 30 31 32 33 z = Columns 1 through 30 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 29 Columns 31 through 35 30 31 32 33 34 z = Columns 1 through 30 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 29 Columns 31 through 36 30 31 32 33 34 35 z = Columns 1 through 30 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 29 Columns 31 through 37 30 31 32 33 34 35 36 z = Columns 1 through 30 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 29 Columns 31 through 38 30 31 32 33 34 35 36 37 z = Columns 1 through 30 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 29 Columns 31 through 39 30 31 32 33 34 35 36 37 38 z = Columns 1 through 30 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 29 Columns 31 through 40 30 31 32 33 34 35 36 37 38 39 z = Columns 1 through 30 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 29 Columns 31 through 41 30 31 32 33 34 35 36 37 38 39 40 z = Columns 1 through 30 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 29 Columns 31 through 42 30 31 32 33 34 35 36 37 38 39 40 41 z = Columns 1 through 30 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 29 Columns 31 through 43 30 31 32 33 34 35 36 37 38 39 40 41 42 z = Columns 1 through 30 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 29 Columns 31 through 44 30 31 32 33 34 35 36 37 38 39 40 41 42 43 z = Columns 1 through 30 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 29 Columns 31 through 45 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 z = Columns 1 through 30 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 29 Columns 31 through 46 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 z = Columns 1 through 30 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 29 Columns 31 through 47 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 z = Columns 1 through 30 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 29 Columns 31 through 48 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 z = Columns 1 through 30 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 29 Columns 31 through 49 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 z = Columns 1 through 30 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 29 Columns 31 through 50 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 z = Columns 1 through 30 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 29 Columns 31 through 51 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 z = Columns 1 through 30 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 29 Columns 31 through 52 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 z = Columns 1 through 30 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 ...

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

m = 129 n = 129 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 = 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 18 z = 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 20 z = 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 22 z = 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 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 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 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 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 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 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 30 z = Columns 1 through 30 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 Column 31 31 z = Columns 1 through 30 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 Columns 31 through 32 31 32 z = Columns 1 through 30 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 Columns 31 through 33 31 32 33 z = Columns 1 through 30 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 Columns 31 through 34 31 32 33 34 z = Columns 1 through 30 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 Columns 31 through 35 31 32 33 34 35 z = Columns 1 through 30 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 Columns 31 through 36 31 32 33 34 35 36 z = Columns 1 through 30 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 Columns 31 through 37 31 32 33 34 35 36 37 z = Columns 1 through 30 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 Columns 31 through 38 31 32 33 34 35 36 37 38 z = Columns 1 through 30 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 Columns 31 through 39 31 32 33 34 35 36 37 38 39 z = Columns 1 through 30 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 Columns 31 through 40 31 32 33 34 35 36 37 38 39 40 z = Columns 1 through 30 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 Columns 31 through 41 31 32 33 34 35 36 37 38 39 40 41 z = Columns 1 through 30 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 Columns 31 through 42 31 32 33 34 35 36 37 38 39 40 41 42 z = Columns 1 through 30 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 Columns 31 through 43 31 32 33 34 35 36 37 38 39 40 41 42 43 z = Columns 1 through 30 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 Columns 31 through 44 31 32 33 34 35 36 37 38 39 40 41 42 43 44 z = Columns 1 through 30 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 Columns 31 through 45 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 z = Columns 1 through 30 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 Columns 31 through 46 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 z = Columns 1 through 30 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 Columns 31 through 47 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 z = Columns 1 through 30 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 Columns 31 through 48 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 z = Columns 1 through 30 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 Columns 31 through 49 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 z = Columns 1 through 30 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 Columns 31 through 50 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 z = Columns 1 through 30 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 Columns 31 through 51 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 z = Columns 1 through 30 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 Columns 31 through 52 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 z = Columns 1 through 30 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 2...

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

m = 844 n = 844 z = 8 z = 8 9 z = 8 9 10 z = 8 9 10 11 z = 8 9 10 11 12 z = 8 9 10 11 12 13 z = 8 9 10 11 12 13 14 z = 8 9 10 11 12 13 14 15 z = 8 9 10 11 12 13 14 15 16 z = 8 9 10 11 12 13 14 15 16 17 z = 8 9 10 11 12 13 14 15 16 17 18 z = 8 9 10 11 12 13 14 15 16 17 18 19 z = 8 9 10 11 12 13 14 15 16 17 18 19 20 z = 8 9 10 11 12 13 14 15 16 17 18 19 20 21 z = 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 z = 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 z = 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 z = 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 z = 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 z = 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 z = 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 z = 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 z = 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 z = 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 = 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 = 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 = 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 = 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 = 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 = 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 30 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 Column 31 38 z = Columns 1 through 30 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 Columns 31 through 32 38 39 z = Columns 1 through 30 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 Columns 31 through 33 38 39 40 z = Columns 1 through 30 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 Columns 31 through 34 38 39 40 41 z = Columns 1 through 30 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 Columns 31 through 35 38 39 40 41 42 z = Columns 1 through 30 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 Columns 31 through 36 38 39 40 41 42 43 z = Columns 1 through 30 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 Columns 31 through 37 38 39 40 41 42 43 44 z = Columns 1 through 30 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 Columns 31 through 38 38 39 40 41 42 43 44 45 z = Columns 1 through 30 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 Columns 31 through 39 38 39 40 41 42 43 44 45 46 z = Columns 1 through 30 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 Columns 31 through 40 38 39 40 41 42 43 44 45 46 47 z = Columns 1 through 30 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 Columns 31 through 41 38 39 40 41 42 43 44 45 46 47 48 z = Columns 1 through 30 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 Columns 31 through 42 38 39 40 41 42 43 44 45 46 47 48 49 z = Columns 1 through 30 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 Columns 31 through 43 38 39 40 41 42 43 44 45 46 47 48 49 50 z = Columns 1 through 30 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 Columns 31 through 44 38 39 40 41 42 43 44 45 46 47 48 49 50 51 z = Columns 1 through 30 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 Columns 31 through 45 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 z = Columns 1 through 30 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 Columns 31 through 46 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 z = Columns 1 through 30 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 Columns 31 through 47 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 z = Columns 1 through 30 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 Columns 31 through 48 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 z = Columns 1 through 30 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 Columns 31 through 49 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 z = Columns 1 through 30 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 Columns 31 through 50 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 z = Columns 1 through 30 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 Columns 31 through 51 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 z = Columns 1 through 30 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 Columns 31 through 52 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 z = Columns 1 through 30 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 3...

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

m = 10 n = 10 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))

m = 5 n = 4 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))

m = 4 n = 9 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

Suggested Problems

More from this Author44

Community Treasure Hunt

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

Start Hunting!