Daily Challenge 248 - Chinese Numerals
Create a function that takes a Number as its argument and returns a Chinese numeral string. You don't need to validate the input argument, it will always be a Number in the range [0, 99999] with no decimals.
Simplified Chinese numerals have characters representing each number from 0 to 9 and additional numbers representing larger numbers like 10, 100, 1000, and 10000.
0 lng 1 y 2 r 3 sn 4 s 5 w 6 li 7 q 8 b 9 ji 10 sh 100 bi 1000 qin 10000 wn
Multiple-digit numbers are constructed by first the digit value (1 to 9) and then the place multiplier (such as 10, 100, 1000), starting with the most significant digit. A special case is made for 10 - 19 where the leading digit value (y ) is dropped. Note that this special case is only made for the actual values 10 - 19, not any larger values. Trailing zeros are omitted, but interior zeros are grouped together and indicated by a single character without giving the place multiplier.
Examples
10
11
18
21
110
123
24681
Tests
to_chinese_numeral(9)
to_chinese_numeral(10)
to_chinese_numeral(110)
to_chinese_numeral(111)
to_chinese_numeral(1000)
to_chinese_numeral(10000)
Good luck!
This challenge comes from ConstableBrew on CodeWars. Thank you to CodeWars, who has licensed redistribution of this challenge under the 2-Clause BSD License!
Want to propose a challenge idea for a future post? Email [email protected] with your suggestions!
Original Link: https://dev.to/thepracticaldev/daily-challenge-248-chinese-numerals-2377
Dev To
An online community for sharing and discovering great ideas, having debates, and making friendsMore About this Source Visit Dev To