Cody

Solution 42523

Submitted on 16 Feb 2012 by JerryJames
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(1): 0 y=0 C=0

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

x(1): 1 y=0 C=1

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

x(1): 0 y=0 C=0 x(2): 1 y=0 C=1

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

x(1): 1 y=0 C=1 x(2): 0 y=1 C=0

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

x(1): 0 y=0 C=0 x(2): 0 y=0 C=0

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

x(1): 1 y=0 C=1 x(2): 1 y=0 C=2

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

x(1): 1 y=0 C=1 x(2): 1 y=0 C=2 x(3): 1 y=0 C=3 x(4): 1 y=0 C=4 x(5): 1 y=0 C=5 x(6): 1 y=0 C=6 x(7): 1 y=0 C=7 x(8): 1 y=0 C=8 x(9): 1 y=0 C=9 x(10): 1 y=0 C=10

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

x(1): 1 y=0 C=1 x(2): 0 y=1 C=0 x(3): 0 y=1 C=0 x(4): 1 y=1 C=1 x(5): 0 y=1 C=0 x(6): 1 y=1 C=1 x(7): 0 y=1 C=0 x(8): 1 y=1 C=1 x(9): 1 y=1 C=2 x(10): 1 y=1 C=3 x(11): 1 y=1 C=4 x(12): 1 y=1 C=5 x(13): 0 y=5 C=0 x(14): 1 y=5 C=1 x(15): 0 y=5 C=0 x(16): 0 y=5 C=0 x(17): 1 y=5 C=1 x(18): 1 y=5 C=2 x(19): 1 y=5 C=3 x(20): 1 y=5 C=4 x(21): 1 y=5 C=5

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

x(1): 0 y=0 C=0 x(2): 1 y=0 C=1 x(3): 0 y=1 C=0 x(4): 1 y=1 C=1 x(5): 0 y=1 C=0 x(6): 1 y=1 C=1 x(7): 0 y=1 C=0 x(8): 1 y=1 C=1 x(9): 0 y=1 C=0 x(10): 1 y=1 C=1 x(11): 0 y=1 C=0 x(12): 1 y=1 C=1 x(13): 0 y=1 C=0 x(14): 1 y=1 C=1 x(15): 0 y=1 C=0 x(16): 1 y=1 C=1 x(17): 0 y=1 C=0 x(18): 1 y=1 C=1 x(19): 0 y=1 C=0 x(20): 1 y=1 C=1 x(21): 0 y=1 C=0 x(22): 1 y=1 C=1 x(23): 0 y=1 C=0 x(24): 1 y=1 C=1 x(25): 0 y=1 C=0 x(26): 1 y=1 C=1

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

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