Cody

# Problem 57. Summing Digits within Text

Solution 1230238

Submitted on 12 Jul 2017 by Salvatore Lacava
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))

alphabet = 'abcdefghHijklmnopqrstuvwxyz?-\$' str = '4 nd 20 bl ckbirds b ked in pie' v = '4 nd 20 bl ckbirds b ked in pie' str = '4 nd 20 l ck irds ked in pie' v = '4 nd 20 l ck irds ked in pie' str = '4 nd 20 l k irds ked in pie' v = '4 nd 20 l k irds ked in pie' str = '4 n 20 l k ir s ke in pie' v = '4 n 20 l k ir s ke in pie' str = '4 n 20 l k ir s k in pi ' v = '4 n 20 l k ir s k in pi ' str = '4 n 20 l k ir s k in pi ' v = '4 n 20 l k ir s k in pi ' str = '4 n 20 l k ir s k in pi ' v = '4 n 20 l k ir s k in pi ' str = '4 n 20 l k ir s k in pi ' v = '4 n 20 l k ir s k in pi ' str = '4 n 20 l k ir s k in pi ' v = '4 n 20 l k ir s k in pi ' str = '4 n 20 l k r s k n p ' v = '4 n 20 l k r s k n p ' str = '4 n 20 l k r s k n p ' v = '4 n 20 l k r s k n p ' str = '4 n 20 l r s n p ' v = '4 n 20 l r s n p ' str = '4 n 20 r s n p ' v = '4 n 20 r s n p ' str = '4 n 20 r s n p ' v = '4 n 20 r s n p ' str = '4 20 r s p ' v = '4 20 r s p ' str = '4 20 r s p ' v = '4 20 r s p ' str = '4 20 r s ' v = '4 20 r s ' str = '4 20 r s ' v = '4 20 r s ' str = '4 20 s ' v = '4 20 s ' str = '4 20 ' v = '4 20 ' str = '4 20 ' v = '4 20 ' str = '4 20 ' v = '4 20 ' str = '4 20 ' v = '4 20 ' str = '4 20 ' v = '4 20 ' str = '4 20 ' v = '4 20 ' str = '4 20 ' v = '4 20 ' str = '4 20 ' v = '4 20 ' str = '4 20 ' v = '4 20 ' str = '4 20 ' v = '4 20 ' str = '4 20 ' v = '4 20 ' total = 24

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

alphabet = 'abcdefghHijklmnopqrstuvwxyz?-\$' str = '2 4 6 8 who do we ppreci te?' v = '2 4 6 8 who do we ppreci te?' str = '2 4 6 8 who do we ppreci te?' v = '2 4 6 8 who do we ppreci te?' str = '2 4 6 8 who do we ppre i te?' v = '2 4 6 8 who do we ppre i te?' str = '2 4 6 8 who o we ppre i te?' v = '2 4 6 8 who o we ppre i te?' str = '2 4 6 8 who o w ppr i t ?' v = '2 4 6 8 who o w ppr i t ?' str = '2 4 6 8 who o w ppr i t ?' v = '2 4 6 8 who o w ppr i t ?' str = '2 4 6 8 who o w ppr i t ?' v = '2 4 6 8 who o w ppr i t ?' str = '2 4 6 8 w o o w ppr i t ?' v = '2 4 6 8 w o o w ppr i t ?' str = '2 4 6 8 w o o w ppr i t ?' v = '2 4 6 8 w o o w ppr i t ?' str = '2 4 6 8 w o o w ppr t ?' v = '2 4 6 8 w o o w ppr t ?' str = '2 4 6 8 w o o w ppr t ?' v = '2 4 6 8 w o o w ppr t ?' str = '2 4 6 8 w o o w ppr t ?' v = '2 4 6 8 w o o w ppr t ?' str = '2 4 6 8 w o o w ppr t ?' v = '2 4 6 8 w o o w ppr t ?' str = '2 4 6 8 w o o w ppr t ?' v = '2 4 6 8 w o o w ppr t ?' str = '2 4 6 8 w o o w ppr t ?' v = '2 4 6 8 w o o w ppr t ?' str = '2 4 6 8 w w ppr t ?' v = '2 4 6 8 w w ppr t ?' str = '2 4 6 8 w w r t ?' v = '2 4 6 8 w w r t ?' str = '2 4 6 8 w w r t ?' v = '2 4 6 8 w w r t ?' str = '2 4 6 8 w w t ?' v = '2 4 6 8 w w t ?' str = '2 4 6 8 w w t ?' v = '2 4 6 8 w w t ?' str = '2 4 6 8 w w ?' v = '2 4 6 8 w w ?' str = '2 4 6 8 w w ?' v = '2 4 6 8 w w ?' str = '2 4 6 8 w w ?' v = '2 4 6 8 w w ?' str = '2 4 6 8 ?' v = '2 4 6 8 ?' str = '2 4 6 8 ?' v = '2 4 6 8 ?' str = '2 4 6 8 ?' v = '2 4 6 8 ?' str = '2 4 6 8 ?' v = '2 4 6 8 ?' str = '2 4 6 8 ' v = '2 4 6 8 ' str = '2 4 6 8 ' v = '2 4 6 8 ' str = '2 4 6 8 ' v = '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))

alphabet = 'abcdefghHijklmnopqrstuvwxyz?-\$' str = 'He worked t the 7-11 for \$10 n hour' v = 'He worked t the 7-11 for \$10 n hour' str = 'He worked t the 7-11 for \$10 n hour' v = 'He worked t the 7-11 for \$10 n hour' str = 'He worked t the 7-11 for \$10 n hour' v = 'He worked t the 7-11 for \$10 n hour' str = 'He worke t the 7-11 for \$10 n hour' v = 'He worke t the 7-11 for \$10 n hour' str = 'H work t th 7-11 for \$10 n hour' v = 'H work t th 7-11 for \$10 n hour' str = 'H work t th 7-11 or \$10 n hour' v = 'H work t th 7-11 or \$10 n hour' str = 'H work t th 7-11 or \$10 n hour' v = 'H work t th 7-11 or \$10 n hour' str = 'H work t t 7-11 or \$10 n our' v = 'H work t t 7-11 or \$10 n our' str = ' work t t 7-11 or \$10 n our' v = ' work t t 7-11 or \$10 n our' str = ' work t t 7-11 or \$10 n our' v = ' work t t 7-11 or \$10 n our' str = ' work t t 7-11 or \$10 n our' v = ' work t t 7-11 or \$10 n our' str = ' wor t t 7-11 or \$10 n our' v = ' wor t t 7-11 or \$10 n our' str = ' wor t t 7-11 or \$10 n our' v = ' wor t t 7-11 or \$10 n our' str = ' wor t t 7-11 or \$10 n our' v = ' wor t t 7-11 or \$10 n our' str = ' wor t t 7-11 or \$10 our' v = ' wor t t 7-11 or \$10 our' str = ' w r t t 7-11 r \$10 ur' v = ' w r t t 7-11 r \$10 ur' str = ' w r t t 7-11 r \$10 ur' v = ' w r t t 7-11 r \$10 ur' str = ' w r t t 7-11 r \$10 ur' v = ' w r t t 7-11 r \$10 ur' str = ' w t t 7-11 \$10 u ' v = ' w t t 7-11 \$10 u ' str = ' w t t 7-11 \$10 u ' v = ' w t t 7-11 \$10 u ' str = ' w 7-11 \$10 u ' v = ' w 7-11 \$10 u ' str = ' w 7-11 \$10 ' v = ' w 7-11 \$10 ' str = ' w 7-11 \$10 ' v = ' w 7-11 \$10 ' str = ' 7-11 \$10 ' v = ' 7-11 \$10 ' str = ' 7-11 \$10 ' v = ' 7-11 \$10 ' str = ' 7-11 \$10 ' v = ' 7-11 \$10 ' str = ' 7-11 \$10 ' v = ' 7-11 \$10 ' str = ' 7-11 \$10 ' v = ' 7-11 \$10 ' str = ' 7 11 \$10 ' v = ' 7 11 \$10 ' str = ' 7 11 10 ' v = ' 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))

alphabet = 'abcdefghHijklmnopqrstuvwxyz?-\$' str = 'th t is 6 of one nd h lf dozen of the other' v = 'th t is 6 of one nd h lf dozen of the other' str = 'th t is 6 of one nd h lf dozen of the other' v = 'th t is 6 of one nd h lf dozen of the other' str = 'th t is 6 of one nd h lf dozen of the other' v = 'th t is 6 of one nd h lf dozen of the other' str = 'th t is 6 of one n h lf ozen of the other' v = 'th t is 6 of one n h lf ozen of the other' str = 'th t is 6 of on n h lf oz n of th oth r' v = 'th t is 6 of on n h lf oz n of th oth r' str = 'th t is 6 o on n h l oz n o th oth r' v = 'th t is 6 o on n h l oz n o th oth r' str = 'th t is 6 o on n h l oz n o th oth r' v = 'th t is 6 o on n h l oz n o th oth r' str = 't t is 6 o on n l oz n o t ot r' v = 't t is 6 o on n l oz n o t ot r' str = 't t is 6 o on n l oz n o t ot r' v = 't t is 6 o on n l oz n o t ot r' str = 't t s 6 o on n l oz n o t ot r' v = 't t s 6 o on n l oz n o t ot r' str = 't t s 6 o on n l oz n o t ot r' v = 't t s 6 o on n l oz n o t ot r' str = 't t s 6 o on n l oz n o t ot r' v = 't t s 6 o on n l oz n o t ot r' str = 't t s 6 o on n oz n o t ot r' v = 't t s 6 o on n oz n o t ot r' str = 't t s 6 o on n oz n o t ot r' v = 't t s 6 o on n oz n o t ot r' str = 't t s 6 o o oz o t ot r' v = 't t s 6 o o oz o t ot r' str = 't t s 6 z t t r' v = 't t s 6 z t t r' str = 't t s 6 z t t r' v = 't t s 6 z t t r' str = 't t s 6 z t t r' v = 't t s 6 z t t r' str = 't t s 6 z t t ' v = 't t s 6 z t t ' str = 't t 6 z t t ' v = 't t 6 z t t ' str = ' 6 z ' v = ' 6 z ' str = ' 6 z ' v = ' 6 z ' str = ' 6 z ' v = ' 6 z ' str = ' 6 z ' v = ' 6 z ' str = ' 6 z ' v = ' 6 z ' str = ' 6 z ' v = ' 6 z ' str = ' 6 ' v = ' 6 ' str = ' 6 ' v = ' 6 ' str = ' 6 ' v = ' 6 ' str = ' 6 ' v = ' 6 ' total = 6

### Community Treasure Hunt

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

Start Hunting!