Cody

Solution 1425230

Submitted on 26 Jan 2018 by Thomas Nelson
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))

hs = 0 n = 1 cs = 0 cs = 0 n = 2 y = 0

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

hs = 0 n = 1 cs = 0 cs = 1 hs = 1 n = 2 y = 1

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

hs = 0 n = 1 cs = 0 cs = 0 n = 2 cs = 1 hs = 1 n = 3 y = 1

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

hs = 0 n = 1 cs = 0 cs = 1 hs = 1 n = 2 cs = 0 n = 3 y = 1

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

hs = 0 n = 1 cs = 0 cs = 0 n = 2 cs = 0 n = 3 y = 0

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

hs = 0 n = 1 cs = 0 cs = 1 hs = 1 n = 2 cs = 2 hs = 2 n = 3 y = 2

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

hs = 0 n = 1 cs = 0 cs = 1 hs = 1 n = 2 cs = 2 hs = 2 n = 3 cs = 3 hs = 3 n = 4 cs = 4 hs = 4 n = 5 cs = 5 hs = 5 n = 6 cs = 6 hs = 6 n = 7 cs = 7 hs = 7 n = 8 cs = 8 hs = 8 n = 9 cs = 9 hs = 9 n = 10 cs = 10 hs = 10 n = 11 y = 10

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

hs = 0 n = 1 cs = 0 cs = 1 hs = 1 n = 2 cs = 0 n = 3 cs = 0 n = 4 cs = 1 n = 5 cs = 0 n = 6 cs = 1 n = 7 cs = 0 n = 8 cs = 1 n = 9 cs = 2 hs = 2 n = 10 cs = 3 hs = 3 n = 11 cs = 4 hs = 4 n = 12 cs = 5 hs = 5 n = 13 cs = 0 n = 14 cs = 1 n = 15 cs = 0 n = 16 cs = 0 n = 17 cs = 1 n = 18 cs = 2 n = 19 cs = 3 n = 20 cs = 4 n = 21 cs = 5 n = 22 y = 5

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

hs = 0 n = 1 cs = 0 cs = 0 n = 2 cs = 1 hs = 1 n = 3 cs = 0 n = 4 cs = 1 n = 5 cs = 0 n = 6 cs = 1 n = 7 cs = 0 n = 8 cs = 1 n = 9 cs = 0 n = 10 cs = 1 n = 11 cs = 0 n = 12 cs = 1 n = 13 cs = 0 n = 14 cs = 1 n = 15 cs = 0 n = 16 cs = 1 n = 17 cs = 0 n = 18 cs = 1 n = 19 cs = 0 n = 20 cs = 1 n = 21 cs = 0 n = 22 cs = 1 n = 23 cs = 0 n = 24 cs = 1 n = 25 cs = 0 n = 26 cs = 1 n = 27 y = 1

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

hs = 0 n = 1 cs = 0 cs = 0 n = 2 cs = 1 hs = 1 n = 3 cs = 0 n = 4 cs = 1 n = 5 cs = 0 n = 6 cs = 1 n = 7 cs = 0 n = 8 cs = 1 n = 9 cs = 2 hs = 2 n = 10 cs = 3 hs = 3 n = 11 cs = 0 n = 12 cs = 0 n = 13 cs = 0 n = 14 cs = 1 n = 15 cs = 0 n = 16 cs = 1 n = 17 cs = 2 n = 18 cs = 3 n = 19 cs = 0 n = 20 cs = 0 n = 21 cs = 0 n = 22 cs = 1 n = 23 cs = 0 n = 24 cs = 1 n = 25 cs = 2 n = 26 cs = 3 n = 27 cs = 0 n = 28 cs = 0 n = 29 cs = 0 n = 30 cs = 1 n = 31 cs = 0 n = 32 cs = 1 n = 33 cs = 0 n = 34 cs = 0 n = 35 cs = 0 n = 36 cs = 0 n = 37 cs = 1 n = 38 cs = 2 n = 39 cs = 3 n = 40 cs = 0 n = 41 cs = 1 n = 42 cs = 2 n = 43 cs = 0 n = 44 cs = 1 n = 45 cs = 0 n = 46 cs = 0 n = 47 cs = 0 n = 48 cs = 0 n = 49 cs = 0 n = 50 cs = 0 n = 51 cs = 0 n = 52 cs = 0 n = 53 cs = 1 n = 54 cs = 2 n = 55 cs = 0 n = 56 cs = 0 n = 57 cs = 0 n = 58 cs = 1 n = 59 cs = 0 n = 60 cs = 0 n = 61 cs = 1 n = 62 cs = 0 n = 63 cs = 0 n = 64 cs = 0 n = 65 cs = 0 n = 66 cs = 0 n = 67 cs = 1 n = 68 cs = 2 n = 69 cs = 3 n = 70 cs = 0 n = 71 cs = 0 n = 72 cs = 0 n = 73 cs = 1 n = 74 cs = 0 n = 75 cs = 0 n = 76 cs = 0 n = 77 cs = 1 n = 78 cs = 2 n = 79 cs = 3 n = 80 cs = 0 n = 81 cs = 1 n = 82 cs = 0 n = 83 cs = 1 n = 84 cs = 0 n = 85 cs = 1 n = 86 cs = 0 n = 87 cs = 0 n = 88 cs = 1 n = 89 cs = 2 n = 90 cs = 0 n = 91 cs = 1 n = 92 cs = 2 n = 93 cs = 0 n = 94 cs = 0 n = 95 cs = 0 n = 96 cs = 0 n = 97 cs = 1 n = 98 cs = 2 n = 99 cs = 3 n = 100 cs = 4 hs = 4 n = 101 y = 4