Programming contests

ECN selejtező programozó csapatverseny, 2014. április 27.

April 27, 2014 10:30 AM – April 27, 2014 3:30 PM

English–Number Translator

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 and Output Specification

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

  1. six
  2. negative seven hundred twenty nine
  3. one million one hundred one
download as text file

Output for Sample Input

  1. 6
  2. -729
  3. 1000101
download as text file
University of Debrecen; Faculty of Informatics; v. 03/01/2019