Discuss / Python / 我的 答案

我的 答案

Topic source

###

def normalize(name): return name[0].upper()+name[1:].lower()

###

def prod(L): return(reduce(lambda x,y:x*y ,L ))

###

def str2float(s): DIGITS = {'0': 0, '1': 1, '2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9} def char2num(s): return DIGITS[s] def fn1(x,y): return x*10+y def fn2(x,y): return x/10+y l = s.split('.') l1 = l[0] l2 = l[1][::-1] return reduce(fn1,map(char2num,l1))+reduce(fn2,map(char2num,l2))/10

金陵童子

#2 Created at ... [Delete] [Delete and Lock User]

优秀


  • 1

Reply