In this problem, you will be given one or more integers in English. Your task is to translate these numbers into their integer representation. The numbers can range from negative 999,999,999 to positive 999,999,999. The following is an exhaustive list of English words that your program must account for:

negative, zero, one, two, three, four, five, six, seven, eight, nine, ten,
eleven, twelve, thirteen, fourteen, fifteen, sixteen, seventeen, eighteen, nineteen,
twenty, thirty, forty, fifty, sixty, seventy, eighty, ninety, hundred,
thousand, million


Notes on input:

  1. Negative numbers will be preceded by the word negative.
  2. The word hundred is not used when thousand could be. For example, 1500 is written one thousand five hundred, not fifteen hundred.


The answers are expected to be on separate lines with a newline after each.

Sample Input

negative seven hundred twenty nine
one million one hundred one

Sample Output


This challenge is provided by the ACM International Collegiate Programming Contest.

Upload Solution

Please log in to submit your solution.


Difficulty (4 votes)
Average test runtime 0.29
Points (changes over time) 10
Tried by 14 users
Solved by 12 users

Global ranking

# Name Runtime Points worth
1 Justin 0.14 18
2 ,s/java/NaN/gi 0.14 17
3 JB 0.17 14
4 Irfan 0.21 12
5 Finn-Lasse 0.26 9
6 Dark 0.28 9
7 Mac 0.28 9
8 IeM 0.28 9
9 Nis 0.35 7
10 Eren B. Yilmaz 0.36 7
11 Sk√łgland 0.37 6
12 Jan 0.63 4