Discuss / Python / homework

homework

Topic source

逝去的9211

#1 Created at ... [Delete] [Delete and Lock User]
    CHAR_TO_INT={'0':0,'1':1,'2':2,'3':3,'4':4,'5':5,'6':6,'7':7,'8':8,'9':9}
    l=s.split('.')
    print(l)
    def f1(x,y):
        return x*10+y
    def f2(x,y=0):
        return x*(0.1)+y
    def chartoint(x):
        return CHAR_TO_INT[x]
    if len(l)==1:
        return (reduce(f1,list(map(chartoint,s))))
    else:
        return reduce(f1,list(map(chartoint,l[0])))+reduce(f2,list(map(chartoint,l[1][::-1])))/10

  • 1

Reply