Cody

Solution 1124393

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

array = 0 0 0 steps = 1×0 empty double row vector steps = 0 0 lengths = 0 y = 0

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

array = 0 1 0 steps = 1 2 steps = 0 1 0 2 lengths = 0 1 y = 1

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

array = 0 0 1 0 steps = 2 3 steps = 0 2 0 3 lengths = 0 1 y = 1

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

array = 0 1 0 0 steps = 1 2 steps = 0 1 0 2 lengths = 0 1 y = 1

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

array = 0 0 0 0 steps = 1×0 empty double row vector steps = 0 0 lengths = 0 y = 0

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

array = 0 1 1 0 steps = 1 3 steps = 0 1 0 3 lengths = 0 2 y = 2

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

array = 0 1 1 1 1 1 1 1 1 1 1 0 steps = 1 11 steps = 0 1 0 11 lengths = 0 10 y = 10

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

array = Columns 1 through 16 0 1 0 0 1 0 1 0 1 1 1 1 1 0 1 0 Columns 17 through 23 0 1 1 1 1 1 0 steps = 1 2 4 5 6 7 8 13 14 15 17 22 steps = 0 1 4 6 8 14 17 0 2 5 7 13 15 22 lengths = 0 1 1 1 5 1 5 y = 5

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

array = Columns 1 through 16 0 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 Columns 17 through 28 1 0 1 0 1 0 1 0 1 0 1 0 steps = Columns 1 through 16 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 Columns 17 through 26 18 19 20 21 22 23 24 25 26 27 steps = 0 2 4 6 8 10 12 14 16 18 20 22 24 26 0 3 5 7 9 11 13 15 17 19 21 23 25 27 lengths = 0 1 1 1 1 1 1 1 1 1 1 1 1 1 y = 1

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

array = Columns 1 through 16 0 0 1 0 1 0 1 0 1 1 1 0 0 0 1 0 Columns 17 through 32 1 1 1 0 0 0 1 0 1 1 1 0 0 0 1 0 Columns 33 through 48 1 0 0 0 0 1 1 1 0 1 1 0 1 0 0 0 Columns 49 through 64 0 0 0 0 0 1 1 0 0 0 1 0 0 1 0 0 Columns 65 through 80 0 0 0 1 1 1 0 0 0 1 0 0 0 1 1 1 Columns 81 through 96 0 1 0 1 0 1 0 0 1 1 0 1 1 0 0 0 Columns 97 through 102 0 1 1 1 1 0 steps = Columns 1 through 16 2 3 4 5 6 7 8 11 14 15 16 19 22 23 24 27 Columns 17 through 32 30 31 32 33 37 40 41 43 44 45 53 55 58 59 61 62 Columns 33 through 48 67 70 73 74 77 80 81 82 83 84 85 86 88 90 91 93 Columns 49 through 50 97 101 steps = Columns 1 through 16 0 2 4 6 8 14 16 22 24 30 32 37 41 44 53 58 0 3 5 7 11 15 19 23 27 31 33 40 43 45 55 59 Columns 17 through 26 61 67 73 77 81 83 85 88 91 97 62 70 74 80 82 84 86 90 93 101 lengths = Columns 1 through 16 0 1 1 1 3 1 3 1 3 1 1 3 2 1 2 1 Columns 17 through 26 1 3 1 3 1 1 1 2 2 4 y = 4