Problem I
Fixing Figures
You have just been hired to the Fixing Good lawyer team as an editor. Your boss, Saul Badman, is an incredible lawyer, but has one small quirk: he always forgets to spell out numbers as words in his reports.
It is customary in formal documents to write out numbers, and unfortunately for Saul, he is dealing with lawsuits which involve lots of numbers. Saul forgets to write out numbers so often that you decide it would be easier to write a program that does the job.
Your task is to translate a given number into the corresponding English word(s). For instance, $5280$ becomes “five thousand two hundred eighty”.
If a number is in the ones place after a number in the tens place, it should have a dash between the words representing the tens and ones places, such as $45$ becoming “forty-five”. This rule applies to thousands as well, such as “forty-five thousand”.
You should not include “and” nor “,” in your answer.
For a full word to number reference, view the following tables:
Ones |
|
$0$ |
zero |
$1$ |
one |
$2$ |
two |
$3$ |
three |
$4$ |
four |
$5$ |
five |
$6$ |
six |
$7$ |
seven |
$8$ |
eight |
$9$ |
nine |
Teens |
|
$11$ |
eleven |
$12$ |
twelve |
$13$ |
thirteen |
$14$ |
fourteen |
$15$ |
fifteen |
$16$ |
sixteen |
$17$ |
seventeen |
$18$ |
eighteen |
$19$ |
nineteen |
Tens |
|
$10$ |
ten |
$20$ |
twenty |
$30$ |
thirty |
$40$ |
forty |
$50$ |
fifty |
$60$ |
sixty |
$70$ |
seventy |
$80$ |
eighty |
$90$ |
ninety |
Powers of Ten
$10^2$ |
hundred |
$10^3$ |
thousand |
$10^6$ |
million |
Also note that if a number is negative, the word “negative” should be prepended to the front of the resulting written number.
Input
The first line of input will be an integer $1 \leq N \leq 1\, 000$, the number of numbers you are to convert to English word(s) The next $N$ lines will each contain an integer $X_ i$ in the range $[-9\, 999\, 999, 9\, 999\, 999]$, the $i^\text {th}$ number you are to convert. Numbers are guaranteed to be integers.
Output
The program should output $N$ lines, with the $i^\text {th}$ line containing the English word(s) for the number $X_ i$ from the input.
Extra whitespace between words will be ignored on this problem.
Sample Input 1 | Sample Output 1 |
---|---|
4 0 5 10 18 |
zero five ten eighteen |
Sample Input 2 | Sample Output 2 |
---|---|
4 -93564 234 -1 1234567 |
negative ninety-three thousand five hundred sixty-four two hundred thirty-four negative one one million two hundred thirty-four thousand five hundred sixty-seven |
Sample Input 3 | Sample Output 3 |
---|---|
4 400 401 410 411 |
four hundred four hundred one four hundred ten four hundred eleven |
Sample Input 4 | Sample Output 4 |
---|---|
4 50 1111 80 100 |
fifty one thousand one hundred eleven eighty one hundred |