Cody

Solution 1124744

Submitted on 16 Feb 2017 by Jihye Sofia Seo
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 diffs = Columns 1 through 16 1 1 2 3 4 5 6 7 8 9 0 0 0 0 0 0 Columns 17 through 29 0 0 0 9 8 7 6 5 4 3 2 1 1 zeros = 11 12 13 14 15 16 17 18 19 nonZeros = Columns 1 through 16 1 2 3 4 5 6 7 8 9 10 20 21 22 23 24 25 Columns 17 through 20 26 27 28 29 zeroStarts = 11 zeroEnds = 19 size = 8 v = 8 lo = 1 lo = 1 lo = 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 diffs = Columns 1 through 16 1 1 0 3 49 3 2 232 3 0 0 0 0 0 0 8 Columns 17 through 24 290 0 0 0 12 323 34 1 zeros = 3 10 11 12 13 14 15 18 19 20 nonZeros = 1 2 4 5 6 7 8 9 16 17 21 22 23 24 zeroStarts = 3 10 18 zeroEnds = 3 15 20 size = 0 5 2 v = 5 lo = 2 lo = 2 lo = 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))

diffs = Columns 1 through 16 1 1 1 0 0 0 0 0 0 0 1 1 1 1 1 1 Columns 17 through 18 0 1 zeros = 4 5 6 7 8 9 10 17 nonZeros = 1 2 3 11 12 13 14 15 16 18 zeroStarts = 4 17 zeroEnds = 10 17 size = 6 0 v = 6 lo = 1 lo = 1 lo = 3 y = 7 3

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

LP = 2 3 diffs = 1 1 2 0 0 1 zeros = 4 5 nonZeros = 1 2 3 6 zeroStarts = 4 zeroEnds = 5 size = 1 v = 1 lo = 1 lo = 1 lo = 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 diffs = Columns 1 through 16 1 1 2 0 0 0 0 0 0 0 0 0 9 0 0 0 Columns 17 through 20 0 0 0 1 zeros = 4 5 6 7 8 9 10 11 12 14 15 16 17 18 19 nonZeros = 1 2 3 13 20 zeroStarts = 4 14 zeroEnds = 12 19 size = 8 5 v = 8 lo = 1 lo = 1 lo = 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 diffs = 1 1 0 0 0 0 0 0 0 0 0 1 1 zeros = 3 4 5 6 7 8 9 10 11 nonZeros = 1 2 12 13 zeroStarts = 3 zeroEnds = 11 size = 8 v = 8 lo = 1 lo = 1 lo = 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 diffs = Columns 1 through 16 1 111 541 0 45 3 0 0 0 15 26 0 4 84 3 84 Columns 17 through 19 0 9 1 zeros = 4 7 8 9 12 17 nonZeros = 1 2 3 5 6 10 11 13 14 15 16 18 19 zeroStarts = 4 7 12 17 zeroEnds = 4 9 12 17 size = 0 2 0 0 v = 2 lo = 2 lo = 2 lo = 6 y = 3 6

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

LP = 1 2 diffs = 1 1 0 1 1 zeros = 3 nonZeros = 1 2 4 5 zeroStarts = 3 zeroEnds = 3 size = 0 v = 0 lo = 1 lo = 1 lo = 2 y = 1 2