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

38

IN

八十九

OUT

89
Login to submit solution


49 symbols pyth
Fri Oct 21 18:33:21 2016 Sait2000
+*T-xJm%Cd64%3tt"十一二三四五六七八九"%Chz64qz"三十八"xJ%Cez64
51 symbols perl
Sat Sep 23 14:39:40 2017 k-mx
print`$^X -pMutf8 -C -E'y/三四五六七八九十/3-90/;s/0\\B//'`
53 symbols perl
Sat Sep 23 13:51:12 2017 k-mx
print`$^X -pMutf8 -C -E'y/三四五六七八九十/3-9/d;s/^3\$/30/'`
86 symbols python3
Thu Oct 8 14:59:31 2015 BogdanShevchenko
a='十一二三四五六七八九'
s=input()
I=a.index(s[0])
print((I,I*10,I*10+a.index(s[-1]))[len(s)-1])
109 symbols haskell
Fri Jul 3 11:52:49 2015 YoshikuniJujo
import Data.List
main=interact$show.i
j=head.(`elemIndices`"零一二三四五六七八九十")
i(e:_:f)=j e*10+i f
i e=sum$j`map`e

View all solutions