def normalize(name):
return (name.capitalize())
def prod(L):
return reduce(lambda x, y: x*y, L)
DIGITS = {'0': 0, '1': 1, '2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9}
a = 0
for n in s:
if n != '.':
a = a + 1
else:
break
def fn(x, y):
return x * 10 + y
def char2num(s):
return DIGITS[s]
b = reduce(fn, map(char2num, s[0:a]))
def fm(x, y):
return x * 0.1 + y
c = reduce(fm, map(char2num, s[:a - len(s): -1]))
d = fm(c, 0)
return b + d
Sign in to make a reply
EverBefore25971
def normalize(name):
return (name.capitalize())
def prod(L):
return reduce(lambda x, y: x*y, L)
DIGITS = {'0': 0, '1': 1, '2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9}
a = 0
for n in s:
if n != '.':
a = a + 1
else:
break
def fn(x, y):
return x * 10 + y
def char2num(s):
return DIGITS[s]
b = reduce(fn, map(char2num, s[0:a]))
def fm(x, y):
return x * 0.1 + y
c = reduce(fm, map(char2num, s[:a - len(s): -1]))
d = fm(c, 0)
return b + d