Cody

# Problem 15. Find the longest sequence of 1's in a binary sequence.

Solution 1363569

Submitted on 30 Nov 2017 by cruxjello Late
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 = '0'; y_correct = 0; assert(isequal(lengthOnes(x),y_correct))

z = 0 y = 0 ii = 0

2   Pass
x = '1'; y_correct = 1; assert(isequal(lengthOnes(x),y_correct))

z = 1 y = 0 ii = 0 ii = 1 y = 1

3   Pass
x = '01'; y_correct = 1; assert(isequal(lengthOnes(x),y_correct))

z = 1 y = 0 ii = 0 ii = 1 y = 1

4   Pass
x = '10'; y_correct = 1; assert(isequal(lengthOnes(x),y_correct))

z = 1 0 y = 0 ii = 0 ii = 1 y = 1

5   Pass
x = '00'; y_correct = 0; assert(isequal(lengthOnes(x),y_correct))

z = 0 y = 0 ii = 0

6   Pass
x = '11'; y_correct = 2; assert(isequal(lengthOnes(x),y_correct))

z = 1 1 y = 0 ii = 0 ii = 1 y = 1 ii = 2 y = 2

7   Pass
x = '1111111111'; y_correct = 10; assert(isequal(lengthOnes(x),y_correct))

z = 1 1 1 1 1 1 1 1 1 1 y = 0 ii = 0 ii = 1 y = 1 ii = 2 y = 2 ii = 3 y = 3 ii = 4 y = 4 ii = 5 y = 5 ii = 6 y = 6 ii = 7 y = 7 ii = 8 y = 8 ii = 9 y = 9 ii = 10 y = 10

8   Pass
x = '100101011111010011111'; y_correct = 5; assert(isequal(lengthOnes(x),y_correct))

z = 1 0 0 1 0 1 0 1 1 1 1 1 0 1 0 0 0 9 0 8 8 y = 0 ii = 0 ii = 1 y = 1 ii = 2 y = 2 ii = 3 y = 3 ii = 4 y = 4 ii = 5 y = 5 ii = 6 y = 6 ii = 7 y = 7 ii = 8 y = 8 ii = 9 y = 9 y = 5

9   Pass
x = '01010101010101010101010101'; y_correct = 1; assert(isequal(lengthOnes(x),y_correct))

z = 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 5 7 2 7 3 0 8 8 y = 0 ii = 0 ii = 1 y = 1 ii = 2 y = 2 ii = 3 y = 3 ii = 4 y = 4 ii = 5 y = 5 ii = 6 y = 6 ii = 7 y = 7 ii = 8 y = 8 ii = 9 y = 9 y = 1

10   Pass
x = '0101010111000101110001011100010100001110110100000000110001001000001110001000111010101001101100001111'; y_correct = 4; assert(isequal(lengthOnes(x),y_correct))

z = Columns 1 through 30 1 0 1 0 1 0 1 1 1 0 0 0 1 0 1 1 1 2 7 4 0 0 7 6 8 5 5 8 6 4 Columns 31 through 60 3 0 9 4 3 8 8 1 2 0 6 5 3 2 4 2 1 5 9 4 3 5 0 8 7 3 1 7 7 3 Columns 61 through 90 1 3 6 3 7 5 1 0 6 0 7 9 9 0 5 6 5 3 4 5 7 6 4 9 4 9 1 4 9 5 Columns 91 through 99 9 9 3 9 9 9 3 6 0 y = 0 ii = 0 ii = 1 y = 1 ii = 2 y = 2 ii = 3 y = 3 ii = 4 y = 4 ii = 5 y = 5 ii = 6 y = 6 ii = 7 y = 7 ii = 8 y = 8 ii = 9 y = 9 ii = 10 y = 10 ii = 11 y = 11 ii = 12 y = 12 ii = 13 y = 13 ii = 14 y = 14 ii = 15 y = 15 ii = 16 y = 16 y = 4