Chinese/Japanese numbers to Arabic numerals

In Chinese and Japanese, here are the numbers one to ten next to the equivelant number:

1一
2二
3三
4四
5五
6六
7七
8八
9九
10十

They are also written in a different way to Arabic numerals:

三十 (three, ten) = 30
四十七 (four, ten, seven) = 47

As you can see, they're written in order from biggest to smallest, except when a number under 10 is used to multiply another number.

Your task is to convent any number under 99 from Chinese/Japanese format to Arabic format.

IN

三十

OUT

30

IN

四十七

OUT

47

IN

六十三

OUT

63

IN

三十八

OUT

28

IN

八十九

OUT

89

Test #4 is wrong. "三十八" is 38. Not 28.

Fri Jul 3 06:32:01 2015


Leave a comment

Parsed as Markdown

Login to leave a comment