WORDNUM - Word To Number

no tags 

In this task you just need to convert a number from its word form to digit form. For example, you should output 1 for 'one', 37000 for 'thirty seven thousand' or 99 for 'ninety nine'. You can assume that output will be >= 0 and < 50000. Also all numbers will be valid i.e output will not have numbers like 023.

Input

First line of input has a single positive integer t = number of test cases. In the next t lines, given a number in word form.

Output

Output the number as specified.

Example

Input:
3
one hundred twenty three
thirty four thousand one hundred eight
eleven

Output:

123
34108
11

Score : Source code length

hide comments
hari123: 2016-11-23 19:55:41

They are using PERL @PERL language, so it happens, no doubt.

hari123: 2016-11-23 19:53:08

I too have that doubt @dwij28

dwij28: 2016-01-20 16:14:12

While trying to achieve a better score I noticed that the unique words possible in input (like one..nine, eleven..nineteen,ten..ninety) have a combined length of around 170 bytes.. The top scores are even less than that.. My question to the best scorers like Mitch and numerix is that how is it possible to get a score less than that ? Is there some standard library function that can help in that ? If you could, please enlighten me on this..

dwij28: 2016-01-20 15:44:53

The case of "zero" is dangerous, gave me two NZECs.. :/ But finally AC.. :)

Mitch Schwartz: 2013-06-22 21:11:27

@Maciej Misiak: None of those are valid inputs.

Maciej Misiak: 2013-06-19 12:27:35

WA as well. Is 'a hundred' valid input? 'hundred'? 'one hundred and seven'?

Ali Kanaan: 2013-03-01 20:20:30

please
I'm a beginner in solving at this site
I'm facing a problem with the limited source size
could I have any help from any body

Last edit: 2013-03-01 20:22:25
Paras Sharma: 2012-02-19 06:07:20

finally got AC...

Bharath Reddy: 2011-12-19 09:17:29

I am getting WA:( though it works properly for the given inputs and also several other inputs I tested. Can anybody tell me a case which can fail my code (exceptions)?

Piotr KÄ…kol: 2011-01-21 17:10:11

The record in not 127, but 103 in Perl by Jander. :-)

Last edit: 2012-06-13 09:55:33

Added by:XeRoN!X
Date:2010-08-24
Time limit:1s
Source limit:1000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: NODEJS OBJC VB.NET
Resource:-