Cody

# Problem 44293. Write out numbers in words

Solution 1262127

Submitted on 4 Sep 2017 by yurenchu
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
filetext = fileread('num2words.m'); assert(isempty(strfind(filetext, 'six hundred and seventy-nine'))) assert(isempty(strfind(filetext, 'one thousand, five hundred and twenty')))

2   Pass
x = 0; y_correct = 'zero'; assert(isequal(num2words(x),y_correct))

ans = 'zero thousand, zero hundred and zeroty-zero' ans = 'DELDELDELzero' ans = 'zero'

3   Pass
x = 1; y_correct = 'one'; assert(isequal(num2words(x),y_correct))

ans = 'zero thousand, zero hundred and zeroty-one' ans = 'DELDELDELone' ans = 'one'

4   Pass
x = 56; y_correct = 'fifty-six' assert(isequal(num2words(x),y_correct))

y_correct = 'fifty-six' ans = 'zero thousand, zero hundred and fivety-six' ans = 'DELDELfifty-six' ans = 'fifty-six'

5   Pass
x = 100; y_correct = 'one hundred'; assert(isequal(num2words(x),y_correct))

ans = 'zero thousand, one hundred and zeroty-zero' ans = 'DELone hundred and DELzero' ans = 'one hundred'

6   Pass
x = 105; y_correct = 'one hundred and five'; assert(isequal(num2words(x),y_correct))

ans = 'zero thousand, one hundred and zeroty-five' ans = 'DELone hundred and DELfive' ans = 'one hundred and five'

7   Pass
x = 245; y_correct = 'two hundred and forty-five'; assert(isequal(num2words(x),y_correct))

ans = 'zero thousand, two hundred and fourty-five' ans = 'DELtwo hundred and forty-five' ans = 'two hundred and forty-five'

8   Pass
x = 679; y_correct = 'six hundred and seventy-nine'; assert(isequal(num2words(x),y_correct))

ans = 'zero thousand, six hundred and seventy-nine' ans = 'DELsix hundred and seventy-nine' ans = 'six hundred and seventy-nine'

9   Pass
x = 1520; y_correct = 'one thousand, five hundred and twenty'; assert(isequal(num2words(x),y_correct))

ans = 'one thousand, five hundred and twoty-zero' ans = 'one thousand, five hundred and twentyDEL' ans = 'one thousand, five hundred and twenty'

10   Pass
x = 9999; y_correct = 'nine thousand, nine hundred and ninety-nine'; assert(isequal(num2words(x),y_correct))

ans = 'nine thousand, nine hundred and ninety-nine' ans = 'nine thousand, nine hundred and ninety-nine' ans = 'nine thousand, nine hundred and ninety-nine'