Problem 44955. Spell the number

Solution 2115616

Submitted on 3 Feb 2020
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
x = '0'; y_correct = 'Zero'; assert(isequal(n2t(x),y_correct), [x ' ' n2t(x)])

2   Pass
x = '0.003'; y_correct = 'Zero point zero zero three'; assert(isequal(n2t(x),y_correct), [x ' ' n2t(x)])

3   Pass
x = '0.'; y_correct = 'Zero'; assert(isequal(n2t(x),y_correct), [x ' ' n2t(x)])

4   Pass
x = '.343'; y_correct = 'Zero point three four three'; assert(isequal(n2t(x),y_correct), [x ' ' n2t(x)])

5   Pass
x = '.'; y_correct = 'Zero'; assert(isequal(n2t(x),y_correct), [x ' ' n2t(x)])

6   Pass
x='23000000011.2330'; y_correct = 'Twenty three billion and eleven point two three three zero'; assert(isequal(n2t(x),y_correct), [x ' ' n2t(x)])

7   Pass
x = '1,700,343.04014'; y_correct = 'One million seven hundred thousand three hundred and forty three point zero four zero one four'; assert(isequal(n2t(x),y_correct), [x ' ' n2t(x)])

8   Pass
x = '4,003,900,030,001'; y_correct = 'Four trillion three billion nine hundred million thirty thousand and one'; assert(isequal(n2t(x),y_correct), [x ' ' n2t(x)])

9   Pass
x = '50506'; y_correct = 'Fifty thousand five hundred and six'; assert(isequal(n2t(x),y_correct), [x ' ' n2t(x)])

10   Pass
x = '5001000'; y_correct = 'Five million one thousand'; assert(isequal(n2t(x),y_correct), [x ' ' n2t(x)])

11   Pass
x = '101000'; y_correct = 'One hundred and one thousand'; assert(isequal(n2t(x),y_correct), [x ' ' n2t(x)])

12   Pass
x = '100003.0000341'; y_correct = 'One hundred thousand and three point zero zero zero zero three four one'; assert(isequal(n2t(x),y_correct), [x ' ' n2t(x)])

13   Pass
x = '3.14159265358979'; y_correct = 'Three point one four one five nine two six five three five eight nine seven nine'; assert(isequal(n2t(x),y_correct), [x ' ' n2t(x)])

14   Pass
x = '0497, 367, 158, 401, 387, 490, 191, 320, 142.72931574943292322499550584316'; y_correct = 'Four hundred and ninety seven septillion three hundred and sixty seven sextillion one hundred and fifty eight quintillion four hundred and one quadrillion three hundred and eighty seven trillion four hundred and ninety billion one hundred and ninety one million three hundred and twenty thousand one hundred and forty two point seven two nine three one five seven four nine four three two nine two three two two four nine nine five five zero five eight four three one six'; assert(isequal(n2t(x),y_correct), [x ' ' n2t(x)])

15   Pass
x = '10000000000000000000000000600000000000000000000000000000000000000'; y_correct = 'Ten vigintillion six hundred thousand decillion'; assert(isequal(n2t(x),y_correct), [x ' ' n2t(x)])

16   Pass
x = '2878366142600744685534686064407323355445697471111330511689595534'; y_correct = 'Two vigintillion eight hundred and seventy eight octillion three hundred and sixty six septillion one hundred and forty two sextillion six hundred quintillion seven hundred and forty four quadrillion six hundred and eighty five trillion five hundred and thirty four billion six hundred and eighty six million sixty four thousand four hundred and seven decillion three hundred and twenty three nonillion three hundred and fifty five octillion four hundred and forty five septillion six hundred and ninety seven sextillion four hundred and seventy one quintillion one hundred and eleven quadrillion three hundred and thirty trillion five hundred and eleven billion six hundred and eighty nine million five hundred and ninety five thousand five hundred and thirty four'; assert(isequal(n2t(x),y_correct), [x ' ' n2t(x)])

17   Pass
x = '34000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001.580023'; y_correct = 'Thirty four centillion and one point five eight zero zero two three'; assert(isequal(n2t(x),y_correct), [x ' ' n2t(x)])

18   Fail
filetext = fileread('n2t.m'); assert(isempty(strfind(filetext, 'regexp'))); assert(isempty(strfind(filetext, 'assert'))); assert(isempty(strfind(filetext, 'eval'))) assert(isempty(strfind(filetext, '!'))) assert(isempty(strfind(filetext, 'eighty seven trillion four'))) assert(isempty(strfind(filetext, 'three point zero four zero one four'))) assert(~isempty(strfind(filetext, 'three'))) assert(~isempty(strfind(filetext, 'n2t'))) assert(isempty(dir ('assert.m'))) assert(isempty(dir ('fileread.m'))) assert(isempty(dir ('isempty.m')))

Assertion failed.