Cody

Problem 57. Summing Digits within Text

Solution 1029205

Submitted on 24 Oct 2016
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   Fail
str = '4 and 20 blackbirds baked in a pie'; total = 24; assert(isequal(number_sum(str),total))

str = 4 and 20 blackbirds baked in a pie str = 2 4 6 8 who do we appreciate? z = 1×8 cell array '2' '4' '6' '8' 'who' 'do' 'we' 'appreciate?' 1 ans = 2 2 ans = 4 3 ans = 6 4 ans = 8 5 ans = who z = 1×8 cell array '2' '4' '6' '8' 'nan' 'do' 'we' 'appreciate?' 6 ans = do z = 1×8 cell array '2' '4' '6' '8' 'nan' 'nan' 'we' 'appreciate?' 7 ans = we z = 1×8 cell array '2' '4' '6' '8' 'nan' 'nan' 'nan' 'appreciate?' 8 ans = appreciate? z = 1×8 cell array '2' '4' '6' '8' 'nan' 'nan' 'nan' 'nan' ans = 2468nannannannan str = 2 4 6 8 who do we appreciate? z = 1×8 cell array '2' '4' '6' '8' 'who' 'do' 'we' 'appreciate?' 1 a = int16 50 2 a = int16 52 3 a = int16 54 4 a = int16 56 5 a = 1×3 int16 row vector 119 104 111 6 a = 1×2 int16 row vector 100 111 7 a = 1×2 int16 row vector 119 101 8 a = 1×11 int16 row vector 97 112 112 114 101 99 105 97 116 101 63

Output argument "total" (and maybe others) not assigned during call to "number_sum". Error in TestPoint1 (line 3) assert(isequal(number_sum(str),total))

2   Fail
str = '2 4 6 8 who do we appreciate?'; total = 20; assert(isequal(number_sum(str),total))

str = 4 and 20 blackbirds baked in a pie str = 2 4 6 8 who do we appreciate? z = 1×8 cell array '2' '4' '6' '8' 'who' 'do' 'we' 'appreciate?' 1 ans = 2 2 ans = 4 3 ans = 6 4 ans = 8 5 ans = who z = 1×8 cell array '2' '4' '6' '8' 'nan' 'do' 'we' 'appreciate?' 6 ans = do z = 1×8 cell array '2' '4' '6' '8' 'nan' 'nan' 'we' 'appreciate?' 7 ans = we z = 1×8 cell array '2' '4' '6' '8' 'nan' 'nan' 'nan' 'appreciate?' 8 ans = appreciate? z = 1×8 cell array '2' '4' '6' '8' 'nan' 'nan' 'nan' 'nan' ans = 2468nannannannan str = 2 4 6 8 who do we appreciate? z = 1×8 cell array '2' '4' '6' '8' 'who' 'do' 'we' 'appreciate?' 1 a = int16 50 2 a = int16 52 3 a = int16 54 4 a = int16 56 5 a = 1×3 int16 row vector 119 104 111 6 a = 1×2 int16 row vector 100 111 7 a = 1×2 int16 row vector 119 101 8 a = 1×11 int16 row vector 97 112 112 114 101 99 105 97 116 101 63

Output argument "total" (and maybe others) not assigned during call to "number_sum". Error in TestPoint2 (line 3) assert(isequal(number_sum(str),total))

3   Fail
str = 'He worked at the 7-11 for \$10 an hour'; total = 28; assert(isequal(number_sum(str),total))

str = 4 and 20 blackbirds baked in a pie str = 2 4 6 8 who do we appreciate? z = 1×8 cell array '2' '4' '6' '8' 'who' 'do' 'we' 'appreciate?' 1 ans = 2 2 ans = 4 3 ans = 6 4 ans = 8 5 ans = who z = 1×8 cell array '2' '4' '6' '8' 'nan' 'do' 'we' 'appreciate?' 6 ans = do z = 1×8 cell array '2' '4' '6' '8' 'nan' 'nan' 'we' 'appreciate?' 7 ans = we z = 1×8 cell array '2' '4' '6' '8' 'nan' 'nan' 'nan' 'appreciate?' 8 ans = appreciate? z = 1×8 cell array '2' '4' '6' '8' 'nan' 'nan' 'nan' 'nan' ans = 2468nannannannan str = 2 4 6 8 who do we appreciate? z = 1×8 cell array '2' '4' '6' '8' 'who' 'do' 'we' 'appreciate?' 1 a = int16 50 2 a = int16 52 3 a = int16 54 4 a = int16 56 5 a = 1×3 int16 row vector 119 104 111 6 a = 1×2 int16 row vector 100 111 7 a = 1×2 int16 row vector 119 101 8 a = 1×11 int16 row vector 97 112 112 114 101 99 105 97 116 101 63

Output argument "total" (and maybe others) not assigned during call to "number_sum". Error in TestPoint3 (line 3) assert(isequal(number_sum(str),total))

4   Fail
str = 'that is 6 of one and a half dozen of the other'; total = 6; assert(isequal(number_sum(str),total))

str = 4 and 20 blackbirds baked in a pie str = 2 4 6 8 who do we appreciate? z = 1×8 cell array '2' '4' '6' '8' 'who' 'do' 'we' 'appreciate?' 1 ans = 2 2 ans = 4 3 ans = 6 4 ans = 8 5 ans = who z = 1×8 cell array '2' '4' '6' '8' 'nan' 'do' 'we' 'appreciate?' 6 ans = do z = 1×8 cell array '2' '4' '6' '8' 'nan' 'nan' 'we' 'appreciate?' 7 ans = we z = 1×8 cell array '2' '4' '6' '8' 'nan' 'nan' 'nan' 'appreciate?' 8 ans = appreciate? z = 1×8 cell array '2' '4' '6' '8' 'nan' 'nan' 'nan' 'nan' ans = 2468nannannannan str = 2 4 6 8 who do we appreciate? z = 1×8 cell array '2' '4' '6' '8' 'who' 'do' 'we' 'appreciate?' 1 a = int16 50 2 a = int16 52 3 a = int16 54 4 a = int16 56 5 a = 1×3 int16 row vector 119 104 111 6 a = 1×2 int16 row vector 100 111 7 a = 1×2 int16 row vector 119 101 8 a = 1×11 int16 row vector 97 112 112 114 101 99 105 97 116 101 63

Output argument "total" (and maybe others) not assigned during call to "number_sum". Error in TestPoint4 (line 3) assert(isequal(number_sum(str),total))