Cody

# Problem 1779. Oh Zero Zero Zero!!!

Solution 2261483

Submitted on 7 May 2020
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 delta = 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 sIdx = 10 eIdx = 19 length = 9 L = 9 maxIdx = 1 P = 10 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 delta = 0 1 -1 0 0 0 0 0 1 0 0 0 0 0 -1 0 1 0 0 -1 0 0 sIdx = 2 9 17 eIdx = 3 15 20 length = 1 6 3 L = 6 maxIdx = 2 P = 9 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))

delta = 0 0 1 0 0 0 0 0 0 -1 0 0 0 0 0 1 sIdx = 3 16 eIdx = 10 length = 7 -6 L = 7 maxIdx = 1 P = 3 y = 7 3

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

LP = 2 3 delta = 0 0 1 0 sIdx = 3 eIdx = 1×0 empty double row vector length = 1×0 empty double row vector L = 1×0 empty double row vector maxIdx = 1×0 empty double row vector P = 1×0 empty double row vector y = 1×0 empty double row vector

Assertion failed.

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 delta = 0 0 1 0 0 0 0 0 0 0 0 -1 1 0 0 0 0 0 sIdx = 3 13 eIdx = 12 length = 9 -1 L = 9 maxIdx = 1 P = 3 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 delta = 0 1 0 0 0 0 0 0 0 0 -1 sIdx = 2 eIdx = 11 length = 9 L = 9 maxIdx = 1 P = 2 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 delta = 0 0 1 -1 0 1 0 0 -1 0 1 -1 0 0 0 1 -1 sIdx = 3 6 11 16 eIdx = 4 9 12 17 length = 1 3 1 1 L = 3 maxIdx = 2 P = 6 y = 3 6

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

LP = 1 2 delta = 0 1 -1 sIdx = 2 eIdx = 3 length = 1 L = 1 maxIdx = 1 P = 2 y = 1 2