Cody

Solution 1718930

Submitted on 1 Feb 2019 by Nikolaos Nikolaou
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))

t1 = 1 s = 1 z = 1 i = 2

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

t1 = 1 s = [] s = 0 z = 0 i = 2

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

t1 = 1 s = 0×1 empty double column vector s = 0 z = 0 i = 2

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

t1 = 1 s = 19 z = 19 i = 2

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

t1 = 544 s = 0×1 empty double column vector s = 0 z = 0 i = 2 s = 1 z = 0 1 i = 3 s = 2 z = 0 1 2 i = 4 s = 3 z = 0 1 2 3 i = 5 s = 4 z = 0 1 2 3 4 i = 6 s = 5 z = 0 1 2 3 4 5 i = 7 s = 6 z = 0 1 2 3 4 5 6 i = 8 s = 7 z = 0 1 2 3 4 5 6 7 i = 9 s = 8 z = 0 1 2 3 4 5 6 7 8 i = 10 s = 9 z = 0 1 2 3 4 5 6 7 8 9 i = 11 s = 10 z = 0 1 2 3 4 5 6 7 8 9 10 i = 12 s = 11 z = 0 1 2 3 4 5 6 7 8 9 10 11 i = 13 s = 12 z = 0 1 2 3 4 5 6 7 8 9 10 11 12 i = 14 s = 13 z = 0 1 2 3 4 5 6 7 8 9 10 11 12 13 i = 15 s = 14 z = 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 i = 16 s = 15 z = 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 i = 17 s = 16 z = 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 i = 18 s = 17 z = 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 i = 19 s = 18 z = 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 i = 20 s = 19 z = 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 i = 21 s = 20 z = 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 i = 22 s = 21 z = 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 i = 23 s = 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 i = 24 s = 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 i = 25 s = 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 i = 26 s = 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 i = 27 s = 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 i = 28 s = 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 i = 29 s = 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 i = 30 s = 29 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 i = 31 s = 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 Column 31 30 i = 32 s = 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 32 30 31 i = 33 s = 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 33 30 31 32 i = 34 s = 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 34 30 31 32 33 i = 35 s = 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 35 30 31 32 33 34 i = 36 s = 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 36 30 31 32 33 34 35 i = 37 s = 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 37 30 31 32 33 34 35 36 i = 38 s = 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 38 30 31 32 33 34 35 36 37 i = 39 s = 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 39 30 31 32 33 34 35 36 37 38 i = 40 s = 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 40 30 31 32 33 34 35 36 37 38 39 i = 41 s = 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 41 30 31 32 33 34 35 36 37 38 39 40 i = 42 s = 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 42 30 31 32 33 34 35 36 37 38 39 40 41 i = 43 s = 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 43 30 31 32 33 34 35 36 37 38 39 40 41 42 i = 44 s = 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 44 30 31 32 33 34 35 36 37 38 39 40 41 42 43 i = 45 s = 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 45 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 i = 46 s = 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 46 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 i = 47 s = 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 47 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 i = 48 s = 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 48 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 i = 49 s = 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 49 3...

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

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

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

t1 = 340 s = 271 z = 271 i = 2 s = 272 z = 271 272 i = 3 s = 273 z = 271 272 273 i = 4 s = 274 z = 271 272 273 274 i = 5 s = 275 z = 271 272 273 274 275 i = 6 s = 276 z = 271 272 273 274 275 276 i = 7 s = 277 z = 271 272 273 274 275 276 277 i = 8 s = 278 z = 271 272 273 274 275 276 277 278 i = 9 s = 279 z = 271 272 273 274 275 276 277 278 279 i = 10 s = 280 z = 271 272 273 274 275 276 277 278 279 280 i = 11 s = 281 z = 271 272 273 274 275 276 277 278 279 280 281 i = 12 s = 282 z = 271 272 273 274 275 276 277 278 279 280 281 282 i = 13 s = 283 z = 271 272 273 274 275 276 277 278 279 280 281 282 283 i = 14 s = 284 z = 271 272 273 274 275 276 277 278 279 280 281 282 283 284 i = 15 s = 285 z = 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 i = 16 s = 286 z = 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 i = 17 s = 287 z = 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 i = 18 s = 288 z = 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 i = 19 s = 289 z = 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 i = 20 s = 290 z = 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 i = 21 s = 291 z = 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 i = 22 s = 292 z = 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 i = 23 s = 293 z = 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 i = 24 s = 294 z = 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 i = 25 s = 295 z = 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 i = 26 s = 296 z = 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 i = 27 s = 297 z = 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 i = 28 s = 298 z = 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 i = 29 s = 299 z = 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 i = 30 s = 300 z = 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 i = 31 s = 301 z = Columns 1 through 30 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 Column 31 301 i = 32 s = 302 z = Columns 1 through 30 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 Columns 31 through 32 301 302 i = 33 s = 303 z = Columns 1 through 30 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 Columns 31 through 33 301 302 303 i = 34 s = 304 z = Columns 1 through 30 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 Columns 31 through 34 301 302 303 304 i = 35 s = 305 z = Columns 1 through 30 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 Columns 31 through 35 301 302 303 304 305 i = 36 s = 306 z = Columns 1 through 30 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 Columns 31 through 36 301 302 303 304 305 306 i = 37 s = 307 z = Columns 1 through 30 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 Columns 31 through 37 301 302 303 304 305 306 307 i = 38 s = 308 z = Columns 1 through 30 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 Columns 31 through 38 301 302 303 304 305 306 307 308 i = 39 s = 309 z = Columns 1 through 30 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 Columns 31 through 39 301 302 303 304 305 306 307 308 309 i = 40 s = 310 z = Columns 1 through 30 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 Columns 31 through 40 301 302 303 304 305 306 307 308 309 310 i = 41 s = 311 z = Columns 1 through 30 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 Columns 31 through 41 301 302 303 304 305 306 307 308 309 310 311 i = 42 s = 312 z = Columns 1 through 30 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 Columns 31 through 42 301 302 303 304 305 306 307 308 309 310 311 312 i = 43 s = 313 z = Columns 1 through 30 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 Columns 31 through 43 301 302 303 304 305 306 307 308 309 310 311 312 313 i = 44 s = 314 z = Columns 1 through 30 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 Columns 31 through 44 301 302 303 304 305 306 307 308 309 310 311 312 313 314 i = 45 s = 315 z = Columns 1 through 30 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 Columns 31 through 45 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 i = 46 s = 316 z = Columns 1 through 30 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 Columns 31 through 46 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 i = 47 s = 317 z = Columns 1 through 30 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 Columns 31 through 47 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 i = 48 s = 318 z = Columns 1 through 30 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 Columns 31 through 48 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 i = 49 s = 319 z = Columns 1 through 30 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 Columns 31 through 49 301 302 303 304 305 306 307 ...

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

t1 = 10 s = 0×1 empty double column vector s = 0 z = 0 i = 2 s = 0×1 empty double column vector s = 0 z = 0 0 i = 3 s = 1 z = 0 0 1 i = 4 s = 0×1 empty double column vector s = 0 z = 0 0 1 0 i = 5 s = 0×1 empty double column vector s = 0 z = 0 0 1 0 0 i = 6 s = 0×1 empty double column vector s = 0 z = 0 0 1 0 0 0 i = 7 s = 0×1 empty double column vector s = 0 z = 0 0 1 0 0 0 0 i = 8 s = 0×1 empty double column vector s = 0 z = 0 0 1 0 0 0 0 0 i = 9 s = 0×1 empty double column vector s = 0 z = 0 0 1 0 0 0 0 0 0 i = 10 s = 0×1 empty double column vector s = 0 z = 0 0 1 0 0 0 0 0 0 0 i = 11

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

t1 = 4 s = 5 z = 5 i = 2 s = 4 z = 5 4 i = 3 s = 0×1 empty double column vector s = 0 z = 5 4 0 i = 4 s = 3 z = 5 4 0 3 i = 5

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

t1 = 9 s = 4 z = 4 i = 2 s = 3 z = 4 3 i = 3 s = 2 z = 4 3 2 i = 4 s = 1 z = 4 3 2 1 i = 5 s = 0×1 empty double column vector s = 0 z = 4 3 2 1 0 i = 6 s = 1 z = 4 3 2 1 0 1 i = 7 s = 2 z = 4 3 2 1 0 1 2 i = 8 s = 3 z = 4 3 2 1 0 1 2 3 i = 9 s = 4 z = 4 3 2 1 0 1 2 3 4 i = 10

Suggested Problems