from itertools import zip_longest
def addition_without_carrying(a, b):
s = ''.join(
str((x + y) % 10)
for x, y in zip_longest(map(int, str(a)[::-1]), map(int, str(b)[::-1]), fillvalue=0)
)
return int(s[::-1])
def addition_without_carrying(a, b):
a, b = str(a), str(b)
l = max(len(a), len(b))
a, b = a.zfill(l), b.zfill(l)
return int(''.join(str((int(m) + int(n)) % 10) for m, n in zip(a, b)))
def addition_without_carrying(a, b):
sa, sb = str(a), str(b)
lmax = max(len(sa), len(sb))
sa, sb = sa.zfill(lmax), sb.zfill(lmax)
return int("".join(str((int(da) + int(db)) % 10) for da, db in zip(sa, sb)))
addition_without_carrying=f=lambda a,b:a+b and f(a//10,b//10)*10+(a+b)%10
from itertools import zip_longest
def addition_without_carrying(num_a, num_b):
digits = [str((int(a) + int(b)) % 10) for a, b in zip_longest(reversed(str(num_a)), reversed(str(num_b)), fillvalue='0')]
return int(''.join(reversed(digits)))
def addition_without_carrying(a,b):
a = str(a)
b = str(b)
a = "0"*(len(b)-len(a)) + a
b = "0"*(len(a)-len(b)) + b
s = int(''.join(str((int(x)+int(y))%10) for x,y in zip(a,b)))
return s
from itertools import zip_longest
def addition_without_carrying(a, b):
return int(''.join(str(int(x) + int(y))[-1] for x, y in zip_longest(str(a)[::-1], str(b)[::-1], fillvalue='0'))[::-1])
def addition_without_carrying(a,b):
if a < b:
a, b = b, a
A, B = str(a).zfill(6), str(b).zfill(6)
return int(''.join([str((int(A[i]) + int(B[i])) % 10) for i in range(6)]))
from itertools import zip_longest
def addition_without_carrying(*args):
args = [map(int, str(i)[::-1]) for i in args]
return int(''.join(str(sum(i)%10) for i in zip_longest(*args, fillvalue=0))[::-1])
def addition_without_carrying(a,b):
#coding and coding..
#make them strings to index into them
a = str(a)[::-1]
b = str(b)[::-1]
#workout the longest number
maxLen = max(len(a), len(b))
#pad both to be the same length
if len(a) < len(b):
a+=("0"*(len(b)-len(a)))
if len(b) < len(a):
b+=("0"*(len(a)-len(b)))
answer = []
for i in range(0, maxLen):
answer.append(str(int(a[i])+int(b[i]))[-1])
print(int(''.join(answer[::-1])))
return int(''.join(answer[::-1]))
景越Python基础训练营QQ群
欢迎各位同学加群讨论,一起学习,共同成长!