Submit | All submissions | Best solutions | Back to list |
WORD2NUM - Word to number |
You will convert numbers from words to numerals.
The numbers will be non-negative integers less than one billion. Their word representations will be <number>s according to the following BNF grammar:
<ones> ::= "one" | "two" | "three" | "four" | "five" | "six" | "seven" | "eight" | "nine"
<tens-place> ::= "twenty" | "thirty" | "forty" | "fifty" | "sixty" | "seventy" | "eighty" | "ninety"
<tens> ::= <ones> | <tens-place> | <tens-place> "-" <ones> | "ten" | "eleven" | "twelve" | "thirteen" | "fourteen" | "fifteen" | "sixteen" | "seventeen" | "eighteen" | "nineteen"
<hundreds> ::= <tens> | <ones> " " "hundred" | <ones> " " "hundred" " " <tens>
<thousands> ::= <hundreds> | <hundreds> " " "thousand" | <hundreds> " " "thousand" " " <hundreds>
<millions> ::= <thousands> | <hundreds> " " "million" | <hundreds> " " "million" " " <thousands>
<number> ::= <millions> | "zero"
Input
The input is the word representation of the number on a single line.
Output
Output the decimal representation of the number.
Examples
Input: zero Output: 0
Input: seventeen Output: 17
Input: fifty-two Output: 52
Input: one thousand one Output: 1001
Input: nine hundred ninety-nine million nine hundred ninety-nine thousand nine hundred ninety-nine Output: 999999999
Added by: | BYU Admin |
Date: | 2015-11-05 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ASM64 MAWK BC NCSHARP COFFEE DART FORTH GOSU JS-MONKEY JULIA KTLN OCT PROLOG PYPY3 R RACKET SQLITE SWIFT UNLAMBDA |