Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
binary adder solution in Clear category for Funny Addition by gm86xx
def checkio(data):
def half_adder(a,b):
c = a and b
s = (a or b) and not c
return (s,c)
def full_adder(a,b,x):
s1,c1 = half_adder(a,b)
s2,c2 = half_adder(s1,x)
return (s2, c1 or c2)
p,q = data
# get binary string, strip '0b' and reverse the order
p = bin(p)[:1:-1]
q = bin(q)[:1:-1]
r = ''
x = False
for i in range(max(len(p),len(q))+1):
# adding each bits
a = i
Sept. 30, 2018