Cody

Solution 2186795

Submitted on 1 Apr 2020 by Simon Hönes
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))

noDigits = 7×1 cell array {0×0 char } {'and' } {'blackbirds'} {'baked' } {'in' } {'a' } {'pie' } noEmptyElements = 6×1 cell array {'and' } {'blackbirds'} {'baked' } {'in' } {'a' } {'pie' } numbers = '4 20 ' splittedNbrs = 3×1 cell array {'4' } {'20' } {0×0 char} nbrsWithoutEmpty = 2×1 cell array {'4' } {'20'} total = 24

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

noDigits = 5×1 cell array {0×0 char } {'who' } {'do' } {'we' } {'appreciate?'} noEmptyElements = 4×1 cell array {'who' } {'do' } {'we' } {'appreciate?'} numbers = '2 4 6 8 ' splittedNbrs = 5×1 cell array {'2' } {'4' } {'6' } {'8' } {0×0 char} nbrsWithoutEmpty = 4×1 cell array {'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))

noDigits = 9×1 cell array {'He' } {'worked'} {'at' } {'the' } {'-' } {'for' } {'$' } {'an' } {'hour' } noEmptyElements = 9×1 cell array {'He' } {'worked'} {'at' } {'the' } {'-' } {'for' } {'$' } {'an' } {'hour' } numbers = ' 7 11 10 ' splittedNbrs = 5×1 cell array {0×0 char} {'7' } {'11' } {'10' } {0×0 char} nbrsWithoutEmpty = 3×1 cell array {'7' } {'11'} {'10'} 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))

noDigits = 11×1 cell array {'that' } {'is' } {'of' } {'one' } {'and' } {'a' } {'half' } {'dozen'} {'of' } {'the' } {'other'} noEmptyElements = 11×1 cell array {'that' } {'is' } {'of' } {'one' } {'and' } {'a' } {'half' } {'dozen'} {'of' } {'the' } {'other'} numbers = ' 6 ' splittedNbrs = 3×1 cell array {0×0 char} {'6' } {0×0 char} nbrsWithoutEmpty = 1×1 cell array {'6'} total = 6

Suggested Problems

More from this Author95