Cody

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

Solution 2176633

Submitted on 26 Mar 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 = '0'; y_correct = 0; assert(isequal(lengthOnes(x),y_correct))

x = ' ' y = 0

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

y = 1

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

x = ' 1' y = 1

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

x = '1 ' y = 1

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

x = ' 0' x = ' ' y = 0

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

y = 1

Assertion failed.

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

y = 1

Assertion failed.

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

x = '1 0101011111010011111' x = '1 101011111010011111' x = '1 1 1011111010011111' x = '1 1 1 11111010011111' x = '1 1 1 11111 10011111' x = '1 1 1 11111 1 011111' x = '1 1 1 11111 1 11111' y = 6

Assertion failed.

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

x = ' 1010101010101010101010101' x = ' 1 10101010101010101010101' x = ' 1 1 101010101010101010101' x = ' 1 1 1 1010101010101010101' x = ' 1 1 1 1 10101010101010101' x = ' 1 1 1 1 1 101010101010101' x = ' 1 1 1 1 1 1 1010101010101' x = ' 1 1 1 1 1 1 1 10101010101' x = ' 1 1 1 1 1 1 1 1 101010101' x = ' 1 1 1 1 1 1 1 1 1 1010101' x = ' 1 1 1 1 1 1 1 1 1 1 10101' x = ' 1 1 1 1 1 1 1 1 1 1 1 101' x = ' 1 1 1 1 1 1 1 1 1 1 1 1 1' y = 13

Assertion failed.

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

x = ' 101010111000101110001011100010100001110110100000000110001001000001110001000111010101001101100001111' x = ' 1 1010111000101110001011100010100001110110100000000110001001000001110001000111010101001101100001111' x = ' 1 1 10111000101110001011100010100001110110100000000110001001000001110001000111010101001101100001111' x = ' 1 1 1 111000101110001011100010100001110110100000000110001001000001110001000111010101001101100001111' x = ' 1 1 1 111 00101110001011100010100001110110100000000110001001000001110001000111010101001101100001111' x = ' 1 1 1 111 0101110001011100010100001110110100000000110001001000001110001000111010101001101100001111' x = ' 1 1 1 111 101110001011100010100001110110100000000110001001000001110001000111010101001101100001111' x = ' 1 1 1 111 1 1110001011100010100001110110100000000110001001000001110001000111010101001101100001111' x = ' 1 1 1 111 1 111 001011100010100001110110100000000110001001000001110001000111010101001101100001111' x = ' 1 1 1 111 1 111 01011100010100001110110100000000110001001000001110001000111010101001101100001111' x = ' 1 1 1 111 1 111 1011100010100001110110100000000110001001000001110001000111010101001101100001111' x = ' 1 1 1 111 1 111 1 11100010100001110110100000000110001001000001110001000111010101001101100001111' x = ' 1 1 1 111 1 111 1 111 0010100001110110100000000110001001000001110001000111010101001101100001111' x = ' 1 1 1 111 1 111 1 111 010100001110110100000000110001001000001110001000111010101001101100001111' x = ' 1 1 1 111 1 111 1 111 10100001110110100000000110001001000001110001000111010101001101100001111' x = ' 1 1 1 111 1 111 1 111 1 100001110110100000000110001001000001110001000111010101001101100001111' x = ' 1 1 1 111 1 111 1 111 1 1 0001110110100000000110001001000001110001000111010101001101100001111' x = ' 1 1 1 111 1 111 1 111 1 1 001110110100000000110001001000001110001000111010101001101100001111' x = ' 1 1 1 111 1 111 1 111 1 1 01110110100000000110001001000001110001000111010101001101100001111' x = ' 1 1 1 111 1 111 1 111 1 1 1110110100000000110001001000001110001000111010101001101100001111' x = ' 1 1 1 111 1 111 1 111 1 1 111 110100000000110001001000001110001000111010101001101100001111' x = ' 1 1 1 111 1 111 1 111 1 1 111 11 100000000110001001000001110001000111010101001101100001111' x = ' 1 1 1 111 1 111 1 111 1 1 111 11 1 0000000110001001000001110001000111010101001101100001111' x = ' 1 1 1 111 1 111 1 111 1 1 111 11 1 000000110001001000001110001000111010101001101100001111' x = ' 1 1 1 111 1 111 1 111 1 1 111 11 1 00000110001001000001110001000111010101001101100001111' x = ' 1 1 1 111 1 111 1 111 1 1 111 11 1 0000110001001000001110001000111010101001101100001111' x = ' 1 1 1 111 1 111 1 111 1 1 111 11 1 000110001001000001110001000111010101001101100001111' x = ' 1 1 1 111 1 111 1 111 1 1 111 11 1 00110001001000001110001000111010101001101100001111' x = ' 1 1 1 111 1 111 1 111 1 1 111 11 1 0110001001000001110001000111010101001101100001111' x = ' 1 1 1 111 1 111 1 111 1 1 111 11 1 110001001000001110001000111010101001101100001111' x = ' 1 1 1 111 1 111 1 111 1 1 111 11 1 11 001001000001110001000111010101001101100001111' x = ' 1 1 1 111 1 111 1 111 1 1 111 11 1 11 01001000001110001000111010101001101100001111' x = ' 1 1 1 111 1 111 1 111 1 1 111 11 1 11 1001000001110001000111010101001101100001111' x = ' 1 1 1 111 1 111 1 111 1 1 111 11 1 11 1 01000001110001000111010101001101100001111' x = ' 1 1 1 111 1 111 1 111 1 1 111 11 1 11 1 1000001110001000111010101001101100001111' x = ' 1 1 1 111 1 111 1 111 1 1 111 11 1 11 1 1 00001110001000111010101001101100001111' x = ' 1 1 1 111 1 111 1 111 1 1 111 11 1 11 1 1 0001110001000111010101001101100001111' x = ' 1 1 1 111 1 111 1 111 1 1 111 11 1 11 1 1 001110001000111010101001101100001111' x = ' 1 1 1 111 1 111 1 111 1 1 111 11 1 11 1 1 01110001000111010101001101100001111' x = ' 1 1 1 111 1 111 1 111 1 1 111 11 1 11 1 1 1110001000111010101001101100001111' x = ' 1 1 1 111 1 111 1 111 1 1 111 11 1 11 1 1 111 001000111010101001101100001111' x = ' 1 1 1 111 1 111 1 111 1 1 111 11 1 11 1 1 111 01000111010101001101100001111' x = ' 1 1 1 111 1 111 1 111 1 1 111 11 1 11 1 1 111 1000111010101001101100001111' x = ' 1 1 1 111 1 111 1 111 1 1 111 11 1 11 1 1 111 1 00111010101001101100001111' x = ' 1 1 1 ...

Assertion failed.