Cody

Problem 1779. Oh Zero Zero Zero!!!

Solution 2799805

Submitted on 6 Aug 2020 by Cassidy Fialkiewicz
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
x = [1 2 3 4 5 6 7 8 9 0 0 0 0 0 0 0 0 0 9 8 7 6 5 4 3 2 1]; LP = [9 10] %[Length Position] assert(isequal(LengthAndPosnZeros(x),LP))

LP = 9 10 last = 1 cur = 1 last = 1 cur = 2 last = 2 cur = 3 last = 3 cur = 4 last = 4 cur = 5 last = 5 cur = 6 last = 6 cur = 7 last = 7 cur = 8 last = 8 cur = 9 last = 9 cur = 0 cur_pos = 10 cur_len = 1 last = 0 cur = 0 cur_len = 2 last = 0 cur = 0 cur_len = 3 last = 0 cur = 0 cur_len = 4 last = 0 cur = 0 cur_len = 5 last = 0 cur = 0 cur_len = 6 last = 0 cur = 0 cur_len = 7 last = 0 cur = 0 cur_len = 8 last = 0 cur = 0 cur_len = 9 last = 0 cur = 9 best_len = 9 best_pos = 10 cur_pos = 0 cur_len = 0 last = 9 cur = 8 last = 8 cur = 7 last = 7 cur = 6 last = 6 cur = 5 last = 5 cur = 4 last = 4 cur = 3 last = 3 cur = 2 last = 2 cur = 1 last = 1 y = 9 10

2   Pass
x = [1 0 3 49 3 2 232 3 0 0 0 0 0 0 8 290 0 0 0 12 323 34]; LP = [6 9] assert(isequal(LengthAndPosnZeros(x),LP))

LP = 6 9 last = 1 cur = 1 last = 1 cur = 0 cur_pos = 2 cur_len = 1 last = 0 cur = 3 best_len = 1 best_pos = 2 cur_pos = 0 cur_len = 0 last = 3 cur = 49 last = 49 cur = 3 last = 3 cur = 2 last = 2 cur = 232 last = 232 cur = 3 last = 3 cur = 0 cur_pos = 9 cur_len = 1 last = 0 cur = 0 cur_len = 2 last = 0 cur = 0 cur_len = 3 last = 0 cur = 0 cur_len = 4 last = 0 cur = 0 cur_len = 5 last = 0 cur = 0 cur_len = 6 last = 0 cur = 8 best_len = 6 best_pos = 9 cur_pos = 0 cur_len = 0 last = 8 cur = 290 last = 290 cur = 0 cur_pos = 17 cur_len = 1 last = 0 cur = 0 cur_len = 2 last = 0 cur = 0 cur_len = 3 last = 0 cur = 12 cur_pos = 0 cur_len = 0 last = 12 cur = 323 last = 323 cur = 34 last = 34 y = 6 9

3   Pass
x = [1 1 0 0 0 0 0 0 0 1 1 1 1 1 1 0]; LP = [7 3]; assert(isequal(LengthAndPosnZeros(x),LP))

last = 1 cur = 1 last = 1 cur = 1 last = 1 cur = 0 cur_pos = 3 cur_len = 1 last = 0 cur = 0 cur_len = 2 last = 0 cur = 0 cur_len = 3 last = 0 cur = 0 cur_len = 4 last = 0 cur = 0 cur_len = 5 last = 0 cur = 0 cur_len = 6 last = 0 cur = 0 cur_len = 7 last = 0 cur = 1 best_len = 7 best_pos = 3 cur_pos = 0 cur_len = 0 last = 1 cur = 1 last = 1 cur = 1 last = 1 cur = 1 last = 1 cur = 1 last = 1 cur = 1 last = 1 cur = 0 cur_pos = 16 cur_len = 1 last = 0 y = 7 3

4   Pass
x = [1 2 0 0]; LP = [2 3] %[Length Position] assert(isequal(LengthAndPosnZeros(x),LP))

LP = 2 3 last = 1 cur = 1 last = 1 cur = 2 last = 2 cur = 0 cur_pos = 3 cur_len = 1 last = 0 cur = 0 cur_len = 2 last = 0 best_len = 2 best_pos = 3 y = 2 3

5   Pass
x = [1 2 0 0 0 0 0 0 0 0 0 9 0 0 0 0 0 0]; LP = [9 3] %[Length Position] assert(isequal(LengthAndPosnZeros(x),LP))

LP = 9 3 last = 1 cur = 1 last = 1 cur = 2 last = 2 cur = 0 cur_pos = 3 cur_len = 1 last = 0 cur = 0 cur_len = 2 last = 0 cur = 0 cur_len = 3 last = 0 cur = 0 cur_len = 4 last = 0 cur = 0 cur_len = 5 last = 0 cur = 0 cur_len = 6 last = 0 cur = 0 cur_len = 7 last = 0 cur = 0 cur_len = 8 last = 0 cur = 0 cur_len = 9 last = 0 cur = 9 best_len = 9 best_pos = 3 cur_pos = 0 cur_len = 0 last = 9 cur = 0 cur_pos = 13 cur_len = 1 last = 0 cur = 0 cur_len = 2 last = 0 cur = 0 cur_len = 3 last = 0 cur = 0 cur_len = 4 last = 0 cur = 0 cur_len = 5 last = 0 cur = 0 cur_len = 6 last = 0 y = 9 3

6   Pass
x = [1 0 0 0 0 0 0 0 0 0 1]; LP = [9 2] %[Length Position] assert(isequal(LengthAndPosnZeros(x),LP))

LP = 9 2 last = 1 cur = 1 last = 1 cur = 0 cur_pos = 2 cur_len = 1 last = 0 cur = 0 cur_len = 2 last = 0 cur = 0 cur_len = 3 last = 0 cur = 0 cur_len = 4 last = 0 cur = 0 cur_len = 5 last = 0 cur = 0 cur_len = 6 last = 0 cur = 0 cur_len = 7 last = 0 cur = 0 cur_len = 8 last = 0 cur = 0 cur_len = 9 last = 0 cur = 1 best_len = 9 best_pos = 2 cur_pos = 0 cur_len = 0 last = 1 y = 9 2

7   Pass
x = [111 541 0 45 3 0 0 0 15 26 0 4 84 3 84 0 9]; LP = [3 6] %[Length Position] assert(isequal(LengthAndPosnZeros(x),LP))

LP = 3 6 last = 1 cur = 111 last = 111 cur = 541 last = 541 cur = 0 cur_pos = 3 cur_len = 1 last = 0 cur = 45 best_len = 1 best_pos = 3 cur_pos = 0 cur_len = 0 last = 45 cur = 3 last = 3 cur = 0 cur_pos = 6 cur_len = 1 last = 0 cur = 0 cur_len = 2 last = 0 cur = 0 cur_len = 3 last = 0 cur = 15 best_len = 3 best_pos = 6 cur_pos = 0 cur_len = 0 last = 15 cur = 26 last = 26 cur = 0 cur_pos = 11 cur_len = 1 last = 0 cur = 4 cur_pos = 0 cur_len = 0 last = 4 cur = 84 last = 84 cur = 3 last = 3 cur = 84 last = 84 cur = 0 cur_pos = 16 cur_len = 1 last = 0 cur = 9 cur_pos = 0 cur_len = 0 last = 9 y = 3 6

8   Pass
x = [1 0 1]; LP = [1 2] %[Length Position] assert(isequal(LengthAndPosnZeros(x),LP))

LP = 1 2 last = 1 cur = 1 last = 1 cur = 0 cur_pos = 2 cur_len = 1 last = 0 cur = 1 best_len = 1 best_pos = 2 cur_pos = 0 cur_len = 0 last = 1 y = 1 2

Suggested Problems

More from this Author17