A=‘123.456’ s=A.partition('.')
def fan(s): return {'0':0,'1':1,'2':2,'3':3,'4':4,'5':5,'6':6,'7':7,'8':8,'9':9}[s]
def fn(x,y): return x*10+y
def kris(x,y): return x/10+y
from functools import reduce print(reduce(fn,map(fan,s[0]))+reduce(kris,map(fan,s[2][-1::-1]))/10)
Sign in to make a reply
RubyDxq
A=‘123.456’ s=A.partition('.')
def fan(s): return {'0':0,'1':1,'2':2,'3':3,'4':4,'5':5,'6':6,'7':7,'8':8,'9':9}[s]
def fn(x,y): return x*10+y
def kris(x,y): return x/10+y
from functools import reduce print(reduce(fn,map(fan,s[0]))+reduce(kris,map(fan,s[2][-1::-1]))/10)