Cody

# Problem 57. Summing Digits within Text

Solution 2577309

Submitted on 18 Jun 2020 by Li Kehan Li
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
str = '4 and 20 blackbirds baked in a pie'; total = 24; assert(isequal(number_sum(str),total))

a = 1 7 8 c = 6 1 e = 2 k = 0 1 -1 ind = 2 num = 1 l = 1 d = 0 0 0 b = '2' d = 4 2 0 p = 7 o = 8 d = 4 2 20 d = 4 0 20 j = 2 total = 24

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

a = 1 3 5 7 c = 2 2 2 e = 1×0 empty double row vector k = 0 0 0 0 ind = 1×0 empty double row vector num = 1×0 empty double row vector l = 0 d = 0 0 0 0 b = '4' d = 2 4 0 0 b = '6' d = 2 4 6 0 b = '8' d = 2 4 6 8 total = 20

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

a = 18 20 21 28 29 c = 2 1 7 1 e = 2 4 k = 0 1 -1 1 -1 ind = 2 4 num = 1 1 l = 2 d = 0 0 0 0 0 b = '1' d = 7 1 0 0 0 p = 20 o = 21 d = 7 1 11 0 0 d = 7 0 11 0 0 j = 2 b = '1' d = 7 0 11 1 0 p = 28 o = 29 d = 7 0 11 1 10 d = 7 0 11 0 10 j = 3 total = 28

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

a = 9 c = [] e = [] k = 0 ind = [] num = [] l = 0 d = 0 total = 6

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!