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 `[-99999.999, 99999.999]`, rounded to 8 decimal places.

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 líng 零
1 yī 一
2 èr 二
3 sān 三
4 sì 四
5 wǔ 五
6 liù 六
7 qī 七
8 bā 八
9 jiǔ 九
10 shí 十
100 bǎi 百
1000 qiān 千
10000 wàn 万
```

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.

```
10 十
11 十一
18 十八
21 二十一
110 一百一十
123 一百二十三
24681 二万四千六百八十一
```

Trailing zeros are omitted, but interior zeros are grouped together and indicated by a single 零 character without giving the place multiplier.

```
10 十
20 二十
104 一百零四
1004 一千零四
10004 一万零四
10000 一万
```

Decimal numbers are constructed by first writing the whole number part, and then inserting a point (diǎn 点), followed by the decimal portion. The decimal portion is expressed using only the digits 0 to 9, without any positional characters and without grouping zeros.

```
0.1 零点一
123.45 一百二十三点四五
```

Negative numbers are the same as other numbers, but add a 负 (fù) before the number.

For more information, please see http://en.wikipedia.org/wiki/Chinese_numerals.

Difficulty: interview

Starter code:

def to_chinese_numeral(n):
	

Solutions:
import re

NEG, DOT, _, *DIGS = "负点 零一二三四五六七八九"
POWS = " 十 百 千 万".split(' ')
NUMS = {str(i):c for i,c in enumerate(DIGS)}
for n in range(10): NUMS[str(n+10)] = POWS[1] + DIGS[n]*bool(n)


def to_chinese_numeral(n):
    ss = str(abs(n)).split('.')
    return NEG*(n<0) + parse(ss[0]) + (len(ss)>1 and decimals(ss[1]) or '')

def decimals(digs): return DOT + ''.join(NUMS[d] for d in digs)

def parse(s):
    if s in NUMS: return NUMS[s]
    s = ''.join(reversed([ NUMS[d] + POWS[i]*(d!='0') for i,d in enumerate(reversed(s)) ]))
    return re.sub(f'零+$|(?<=零)零+', '', s)

numerals = {
        "-":"负",
        ".":"点",
        0:"零",
        1:"一",
        2:"二",
        3:"三",
        4:"四",
        5:"五",
        6:"六",
        7:"七",
        8:"八",
        9:"九",
        10:"十",
        100:"百",
        1000:"千",
        10000:"万"
    }

def to_chinese_numeral(n, keep_ten=False, trailing_zero=False):
    if trailing_zero: return numerals[0] + to_chinese_numeral(n, keep_ten)
    if n < 0: return numerals['-'] + to_chinese_numeral(-n)
    if n % 1: return to_chinese_numeral(n // 1) + numerals['.'] + ''.join(numerals[int(d)] for d in str(n).split('.')[1])
    if n >= 10000: return to_chinese_numeral(n // 10000) + numerals[10000] + bool(n % 10000) * to_chinese_numeral(n % 10000, True, n % 10000 < 10000 // 10)
    if n >= 1000: return numerals[n // 1000] + numerals[1000] + bool(n % 1000) * to_chinese_numeral(n % 1000, True, n % 1000 < 1000 // 10)
    if n >= 100: return numerals[n // 100] + numerals[100] + bool(n % 100) * to_chinese_numeral(n % 100, True, n % 100 < 100 // 10)
    if n >= 10: return bool(keep_ten or n // 10 > 1) * numerals[n // 10] + numerals[10] + bool(n % 10) * to_chinese_numeral(n % 10, True)
    return numerals[n]

def to_chinese_numeral(n):
    return Chinese_Encoder(n).translated()
    
class Chinese_Encoder(object):
    def __init__(self, number ):
        self.number     = abs(number) 
        self.minus      = ('',"负")[number<0]
        self.str_num    = str(self.number)
        self.translated = (self.encod, self.encod_dec)[type(number) == float]
        
    @property
    def get_tenth(self):
        return [self._translate(f"1{'0'* i}") for i in range(1,len(self.str_num))][::-1]
            
    @property
    def get_num(self):
        return list(map(self._translate, self.str_num))
    
    @staticmethod
    def _translate(n):
        return {  0:"零", 1:"一", 2:"二", 3:"三", 4:"四", 5:"五",
                  6:"六" ,7:"七", 8:"八", 9:"九", 10:"十", 100:"百", 1000:"千", 10000:"万" }.get(int(n))
            
    def encod(self):
        if self.number < 20: return f'{self.minus}{self._translate(self.str_num)}' if self.number <= 10 else f'{self.minus}十{self.get_num[-1]}'
        list_num ,tenth, nums = [self.minus], self.get_tenth, self.get_num
        for i, n in enumerate(nums[:-1]):
            if n != '零':  list_num.append(f'{n}{tenth[i]}')
            if n == '零' and list_num[-1] != n:  list_num.append(n)
        return ''.join(list_num + [nums[-1]]).strip('零')
                
    def encod_dec(self): 
        dot = self.str_num.find('.')
        return f'{self.minus}{ Chinese_Encoder(int(self.str_num[:dot])).translated() }点{"".join(map(self._translate, self.str_num[dot+1:] ))}'


def to_chinese_numeral(n):
    numerals = {
        "-":"负",
        ".":"点",
        0:"零",
        1:"一",
        2:"二",
        3:"三",
        4:"四",
        5:"五",
        6:"六",
        7:"七",
        8:"八",
        9:"九",
        10:"十",
        100:"百",
        1000:"千",
        10000:"万"
    }
    lst=[]
    counter1=n
    newstr=''
    digits='123456789'
    if counter1==0:
        return numerals[0]
    if counter1<0:
        lst.append(numerals["-"])
        counter1*=-1
    read=str(counter1).split('.')
    if len(read[0])==5:
        lst.append(numerals[int(read[0][0])])
        lst.append(numerals[10000])
        if read[0][1] in digits:
            lst.append(numerals[int(read[0][1])])
            lst.append(numerals[1000])
        if read[0][1] not in digits:
            if read[0][2] in digits:
                lst.append(numerals[0])
        if read[0][2] in digits:
            lst.append(numerals[int(read[0][2])])
            lst.append(numerals[100])
        if read[0][2] not in digits:
            if read[0][3] in digits:
                lst.append(numerals[0])
        if read[0][3] in digits:
            if read[0][3]=='1':
                lst.append(numerals[1])
                lst.append(numerals[10])
            elif read[0][3]!='1':
                lst.append(numerals[int(read[0][3])])
                lst.append(numerals[10])
        if read[0][3] not in digits:
            if read[0][4] in digits:
                lst.append(numerals[0])
        if read[0][4] in digits:
            lst.append(numerals[int(read[0][4])])
    if len(read[0])==4:
        lst.append(numerals[int(read[0][0])])
        lst.append(numerals[1000])
        if read[0][1] in digits:
            lst.append(numerals[int(read[0][1])])
            lst.append(numerals[100])
        if read[0][1] not in digits:
            if read[0][2] in digits:
                lst.append(numerals[0])
        if read[0][2] in digits:
            if read[0][2]=='1':
                lst.append(numerals[1])
                lst.append(numerals[10])
            elif read[0][2]!='1':
                lst.append(numerals[int(read[0][2])])
                lst.append(numerals[10])
        if read[0][2] not in digits:
            if read[0][3] in digits:
                lst.append(numerals[0])
        if read[0][3] in digits:
            lst.append(numerals[int(read[0][3])])
    if len(read[0])==3:
        lst.append(numerals[int(read[0][0])])
        lst.append(numerals[100])
        if read[0][1] in digits:
            if read[0][1]==1:
                lst.append(numerals[1])
                lst.append(numerals[10])
            if read[0][1]!=1:
                lst.append(numerals[int(read[0][1])])
                lst.append(numerals[10])
        if read[0][1] not in digits:
            if read[0][2] in digits:
                lst.append(numerals[0])
        if read[0][2] in digits:
            lst.append(numerals[int(read[0][2])])
    if len(read[0])==2:
        if read[0][0]=='1':
            lst.append(numerals[10])
        if read[0][0]!='1':
            lst.append(numerals[int(read[0][0])])
            lst.append(numerals[10])
        if read[0][1] in digits:
            lst.append(numerals[int(read[0][1])])
    if len(read[0])==1:
        lst.append(numerals[int(read[0])])
    if '.' in str(n):
        lst.append(numerals['.'])
        counter2=round(n,8)
        read2=str(counter2).split('.')
        if len(read2[1])==1:
            lst.append(numerals[int(read2[1][0])])
        if len(read2[1])==2:
            lst.append(numerals[int(read2[1][0])])
            lst.append(numerals[int(read2[1][1])])
        if len(read2[1])==3:
            lst.append(numerals[int(read2[1][0])])
            lst.append(numerals[int(read2[1][1])])
            lst.append(numerals[int(read2[1][2])])
        if len(read2[1])==4:
            lst.append(numerals[int(read2[1][0])])
            lst.append(numerals[int(read2[1][1])])
            lst.append(numerals[int(read2[1][2])])
            lst.append(numerals[int(read2[1][3])])
        if len(read2[1])==5:
            lst.append(numerals[int(read2[1][0])])
            lst.append(numerals[int(read2[1][1])])
            lst.append(numerals[int(read2[1][2])])
            lst.append(numerals[int(read2[1][3])])
            lst.append(numerals[int(read2[1][4])])
        if len(read2[1])==6:
            lst.append(numerals[int(read2[1][0])])
            lst.append(numerals[int(read2[1][1])])
            lst.append(numerals[int(read2[1][2])])
            lst.append(numerals[int(read2[1][3])])
            lst.append(numerals[int(read2[1][4])])
            lst.append(numerals[int(read2[1][5])])
        if len(read2[1])==7:
            lst.append(numerals[int(read2[1][0])])
            lst.append(numerals[int(read2[1][1])])
            lst.append(numerals[int(read2[1][2])])
            lst.append(numerals[int(read2[1][3])])
            lst.append(numerals[int(read2[1][4])])
            lst.append(numerals[int(read2[1][5])])
            lst.append(numerals[int(read2[1][6])])
        if len(read2[1])==8:
            lst.append(numerals[int(read2[1][0])])
            lst.append(numerals[int(read2[1][1])])
            lst.append(numerals[int(read2[1][2])])
            lst.append(numerals[int(read2[1][3])])
            lst.append(numerals[int(read2[1][4])])
            lst.append(numerals[int(read2[1][5])])
            lst.append(numerals[int(read2[1][6])])
            lst.append(numerals[int(read2[1][7])])
    newstr=''.join(lst)
    return newstr

from itertools import starmap

numerals = {
    "-":"负",
    ".":"点",
    '0':"零",
    '1':"一",
    '2':"二",
    '3':"三",
    '4':"四",
    '5':"五",
    '6':"六",
    '7':"七",
    '8':"八",
    '9':"九",
    1:"",
    2:"十",
    3:"百",
    4:"千",
    5:"万"
}

def helper(i, s):
    if i:
        return ''.join(map(numerals.get, s))
    l, res = len(s), []
    for j,c in enumerate(s):
        if c == '0':
            if i or not (res and res[-1] == numerals[c]):
                res.append(numerals[c])
        else:
            if j or c != '1' or l != 2:
                res.append(numerals[c])
            res.append(numerals[l-j])
    if res[0] != res[-1] == numerals['0']:
        del res[-1]
    return ''.join(res)

def to_chinese_numeral(n):
    x, s = '', str(n)
    if s[0] == '-': x, s = numerals['-'], s[1:]
    return x + numerals['.'].join(starmap(helper, enumerate(s.split('.'))))

def to_chinese_numeral(n):
    numerals = {"-":"负", ".":"点", 0:"零", 1:"一", 2:"二", 3:"三", 4:"四", 5:"五", 6:"六", 7:"七", 8:"八", 9:"九", 10:"十", 100:"百", 1000:"千", 10000:"万"}
    start, end = '', ''
    if str(n).count('.') == 1:
        end, s = numerals['.'], str(n)
        for i in range(s.index('.') + 1, len(s)):
            end += numerals[int(s[i])]
        n = int(s[:s.index('.')])
    if n < 0:
        start += numerals['-']
        n *= -1
    if n < 11:
        start += numerals[n]
        return start + end
    elif n < 20:
        return start + numerals[10] + numerals[n % 10]
    tth, n = n // 10000, n - n // 10000 * 10000
    th, n = n // 1000, n - n // 1000 * 1000
    h, n = n // 100, n - n // 100 * 100
    t, n = n // 10, n - n // 10 * 10
    if tth > 0 and th == h == t == n == 0:
        start += numerals[tth] + numerals[10000]
    else:
        if tth > 0:
            start += numerals[tth] + numerals[10000]
        if th > 0 and h == t == n == 0:
            start += numerals[th] + numerals[1000]
        else:
            if th > 0:
                start += numerals[th] + numerals[1000]
            elif tth > 0 and th == 0:
                start += numerals[0]
            if h > 0 and t == n == 0:
                start += numerals[h] + numerals[100]
            else:
                if h > 0:
                    start += numerals[h] + numerals[100]
                elif th > 0 and h == 0:
                    start += numerals[0]
                if t > 0:
                    start += numerals[t] + numerals[10]
                elif h > 0 and t == 0:
                    start += numerals[0]
                if n > 0:
                    start += numerals[n]
    
    return start + end


import re, math
numerals = {
        "-":"负",
        ".":"点",
        0:"零",
        1:"一",
        2:"二",
        3:"三",
        4:"四",
        5:"五",
        6:"六",
        7:"七",
        8:"八",
        9:"九",
        10:"十",
        100:"百",
        1000:"千",
        10000:"万"
    }

def decimal(n):
    out = []
    for x in list(n):
        out.append(numerals[int(x)])
    return ''.join(out)
def to_chinese_numeral(n):
    c, bla = divmod(n, 10)
    a, shi = divmod(c, 10)
    b, bai = divmod(a, 10)
    wan, qian = divmod(b, 10) 
    if n == 0:
        return numerals[0]
    if n < 0:
        return numerals['-'] + to_chinese_numeral(-n)

    if isinstance(n, float):
        b = ''.join(re.findall('[\.][0-9]+', str(n)))[1:]
        return to_chinese_numeral(int(''.join(re.findall('[0-9]+[\.]', str(n)))[:-1])) + numerals['.'] + decimal(b) 
    a = [wan, 10000, qian, 1000, bai, 100, shi, 10, bla]

    b = ''.join(numerals[x] for x in a)
    out = re.sub('[零]*$', '', b)
    out = re.sub('[零]{2,}', '零', out)
    out = re.sub('零.', '零', out)
    out = re.sub('[零]{2,}', '零', out)
    out = re.sub('^零', '', out)
    out = re.sub('^一十', '十', out)
    out = re.sub('[零]*$', '', out)
    return out


def to_chinese_numeral(n):
    return Chinese_Encoder(n).translated()
    
class Chinese_Encoder(object):
    def __init__(self, number ):
        self.number  = abs(number)
        self.sign    = Sing(str(self.number), ('',"负")[number<0], isinstance(number,float))
        self.get_num = lambda nums=self.sign.str: "".join(map(self._translate, nums))
        
    @property
    def get_tenth(self):
        return [self._translate(f"1{'0'* i}") for i in range(1,len(self.sign.str))][::-1]
    
    @staticmethod
    def _translate(n):
        return {  0:"零", 1:"一", 2:"二", 3:"三", 4:"四", 5:"五", 6:"六", 7:"七", 
                  8:"八", 9:"九", 10:"十", 100:"百", 1000:"千", 10000:"万" }.get(int(n))
    
    def _encod(self):
        if self.number < 20: return self._translate(self.sign.str) if self.number <= 10 else f'十{self.get_num()[-1]}'
        list_num ,tenth, nums = [''], self.get_tenth, self.get_num()
        for i, n in enumerate(nums[:-1]):
            if n != '零':  list_num.append(f'{n}{tenth[i]}')
            if n == '零' and list_num[-1] != n:  list_num.append(n)
        return ''.join(list_num + [nums[-1]]).strip('零')
                
    def _encod_dec(self): 
        return f'{ Chinese_Encoder(int(self.sign.str[:self.sign.dot_p])).translated() }{self.sign.dot}{self.get_num(self.sign.str[self.sign.dot_p+1:])}'
    
    def translated(self):
        method = (self._encod, self._encod_dec)[self.sign.is_float]
        return f'{self.sign.minus}{method()}'
    
class Sing:
    def __init__(self, find_d, minus, is_float):
        self.dot_p    = find_d.find('.')
        self.minus    = minus
        self.is_float = is_float
        self.dot , self.str = '点', find_d

import re

def to_chinese_numeral(n):
    numerals = {
        "-":"负",
        ".":"点",
        0:"零",
        1:"一",
        2:"二",
        3:"三",
        4:"四",
        5:"五",
        6:"六",
        7:"七",
        8:"八",
        9:"九",
        10:"十",
        100:"百",
        1000:"千",
        10000:"万"
    }
    
    # Extract plus_minus, whole number part, decimal part
    plus_minus, num_part, dec_part = re.search(r'^(-)?(\d+)(?:\.(\d+))?$', str(round(n, 8))).groups()
    
    # plus or minus
    plus_minus = numerals['-'] if plus_minus else ''
    
    # Whole number part
    num_len = len(num_part)
    num_chinese = ''

    if num_len == 1:
        num_chinese = numerals[int(num_part)] # Return numeral if num part has length 1 
    else:
        num_rev = num_part[::-1] # Reverse whole number part

        for i in range(num_len-1, -1, -1):
            digit_value = int(num_rev[i])
            digit_value_chinese = numerals[digit_value]
            place_multi_chinese = numerals[int(10 ** i)]

            if i == 1:
                # handle tens' and unit place
                if num_len > 2:
                    if digit_value > 0:
                        num_chinese += digit_value_chinese + place_multi_chinese
                        if num_rev[i-1] == '0': # omit last digit if it's a zero
                            break
                    else:
                        # handle special case for interior zeros
                        if sum(int(num_rev[j]) for j in range(i, -1, -1)) > 0:
                            num_chinese += numerals[0]
                else:
                    # handle special case for 10-19
                    if digit_value == 1:
                        num_chinese += place_multi_chinese
                        if num_rev[i-1] == '0':
                            break
                    else:
                        num_chinese += digit_value_chinese + place_multi_chinese
                        if num_rev[i-1] == '0': # omit last digit if it's a zero
                            break
            else:
                # handle digits above tens' place
                if digit_value > 0:
                    if digit_value != 0:
                        num_chinese += digit_value_chinese
                        if i > 0:
                            num_chinese += place_multi_chinese
                else:
                    # handle special case for interior zeros
                    if sum(int(num_rev[j]) for j in range(i)) > 0 and num_rev[i-1] != '0':
                        num_chinese += numerals[0]
        
    # decimal part
    if dec_part:
        dec_len = len(dec_part)
        dec_chinese = numerals['.']
        for i in range(dec_len):
            dec_chinese += numerals[int(dec_part[i])]
    else:
        dec_chinese = ''
    
    return '{}{}{}'.format(plus_minus, num_chinese, dec_chinese)


numerals = {
    "0": "零",
    "1": "一",
    "2": "二",
    "3": "三",
    "4": "四",
    "5": "五",
    "6": "六",
    "7": "七",
    "8": "八",
    "9": "九",
}
def to_chinese_numeral(n):
    tempdivide = 10000
    allweishu = []
    allxiaoshu = []
    n = str(n)
    if("-" in n):
        allweishu.append("负")
        n = n[1:]
    else:
        allweishu.append("")
    if("." in n):
        tempxiaoshu = n.split(".")[1]
        n = n.split(".")[0]
        for xiaoshu in tempxiaoshu:
            allxiaoshu.append(numerals[xiaoshu])
    n = int(n)
    # print(allxiaoshu)
    while(tempdivide != 0.1):
        weishu = str(int(n//tempdivide))
        n = n % tempdivide
        allweishu.append(numerals[weishu])
        tempdivide = tempdivide/10
    start = 0
    nums = ["万","千",'百','十','']
    allstrs = allweishu[0]
    for weishu in range(len(allweishu[1:])):
        if(start == 1 and allweishu[weishu+1] == "零" and nums[weishu] != "" and allstrs[-1] != "零"):
            allstrs += "零"
        elif(allweishu[weishu+1] != "零"):

            start = 1
            if(nums[weishu] == "十" and allweishu[weishu+1] == "一"):
                if((allstrs == "" or allstrs == "负")):
                    allstrs += "十"
                elif(allweishu[-1] == "零"):
                    allstrs += "一十"
                elif((allstrs == "" or allstrs == "负") and allweishu[-1] == "零"):
                    allstrs += "十"
                else:
                    allstrs += "一十"

            else:
                allstrs += allweishu[weishu+1]
                allstrs += nums[weishu]
        elif(allweishu[weishu+1] == "零" and nums[weishu] == ""):
            continue

    # print(allweishu)
    # print(allstrs)

    if(len(allstrs) > 1 and allstrs[-1] == "零" ):
        allstrs = allstrs[:-1]
    if(allstrs == "负" or allstrs == ""):
        allstrs += "零"
    if(allxiaoshu):
        allstrs += "点"
        for i in allxiaoshu:
            allstrs += i
    if(allstrs == ""):
        return "零"
    if(allstrs[-1] == "零" and len(allstrs) > 1):
        # print(allstrs)
        return allstrs[:-1]
    # print(allstrs)
    return allstrs