In Chinese, numbers are written as follows:
1 一
2 二
3 三
4 四
5 五
6 六
7 七
8 八
9 九
10 十
For numbers above 10, it is expressed as the number of tens and the number of ones. If there is only one ten, you do not need to explicitly say one, and if there are no ones, you don't need to put anything after:
11 十一
24 二十四
83 八十三
90 九十
For numbers above 100, you use the same logic, but with the character 百
. This time though, if there is only one hundred, you still need to write it out, and if there are no tens, you need to say 零
.
100 一百
231 二百三十一
803 八百零三
999 九百九十九
Your task is to convert these Chinese numerals into Arabic numerals. Given a number N in Chinese (一
(1) <= N <= 九百九十九
(999)), convert it into an Arabic number.
Remember, this is code-golf, so the code with the smallest number of bytes wins.
503
and380
? \$\endgroup\$503 -> 五百三
and380 -> 三百八十
. Also, you say for tens thatyou do not need to explicitly say one
. Does that mean it doesn't matter if we do? \$\endgroup\$五百零三
as there are no tens (I think) \$\endgroup\$