Setting

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

Input

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.

Output

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

Sample Input

six
negative seven hundred twenty nine
one million one hundred one

Sample Output

6
-729
1000101

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

Upload Solution

Please log in to submit your solution.

Statistics

Difficulty (4 votes)
Average test runtime 0.29
Points (changes over time) 10
Tried by 13 users
Solved by 11 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 Finn-Lasse 0.26 10
5 Dark 0.28 9
6 Mac 0.28 9
7 IeM 0.28 9
8 Nis 0.35 7
9 Eren B. Yilmaz 0.36 7
10 Sk√łgland 0.37 7
11 Jan 0.63 4