from functools import reduce
def normalize(name):
return name[:1].upper() + name[1:].lower()
def prod(L):
return reduce(lambda x,y: x*y, L)
def str2float(s):
position = s.find('.')
s1 = s[:position]
s2 = s[position+1:]
def switch1(s1):
digits = {'0':0,'1':1,'2':2,'3':3,'4':4,
'5':5,'6':6,'7':7,'8':8,'9':9}
return digits[s1]
def switch2(x,y):
return x*10 + y
return reduce(switch2, map(switch1, s1)) + reduce(switch2, map(switch1,s2))*pow(0.1,len(s2))
Sign in to make a reply
Tired 2Moon
from functools import reduce
def normalize(name):
return name[:1].upper() + name[1:].lower()
def prod(L):
return reduce(lambda x,y: x*y, L)
def str2float(s):
position = s.find('.')
s1 = s[:position]
s2 = s[position+1:]
def switch1(s1):
digits = {'0':0,'1':1,'2':2,'3':3,'4':4,
'5':5,'6':6,'7':7,'8':8,'9':9}
return digits[s1]
def switch2(x,y):
return x*10 + y
return reduce(switch2, map(switch1, s1)) + reduce(switch2, map(switch1,s2))*pow(0.1,len(s2))