DWITE '11 R1 #1 - Arab-lish Numbers

View as PDF

Submit solution

Points: 5
Time limit: 2.0s
Memory limit: 64M

Problem type
DWITE, October 2011, Problem 1

Arabic is a very peculiar language: unlike English and many others, it is written from right to left. However, the numbers are still written from left to right, and this can cause some problems (especially when the numbers get large). Imagine writing English in this manner (let's call this language "Arab-lish"):

elbat eht no selppa 199 era ereht

The above sentence reads: there are 199 apples on the table. Notice that the number is still written as 199, not 991. Given sentences written in Arab-lish, translate them to English (keeping in mind the special case for numbers).

There will be 5 lines of input, each an Arab-lish sentence consisting of alphanumeric words (a-z, A-Z, 0-9) separated by single spaces. Each line is at most 255 characters long.

Your program should output 5 lines of output, each an English translation from the corresponding Arab-lish sentence.

Note: in the second test input, the word abc123 is not a number (it has letter characters), so it is flipped in the translation to 321cba.

Sample Input

tsetnoc siht ni snoitseuq 5 era ereht
ABC 123 abc123

Sample Output

there are 5 questions in this contest
321cba 123 CBA

Problem Resource: DWITE

Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported

Comments

There are no comments at the moment.