Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Multiplication Table by TurboProNiszczyciel
def checkio(first, second):
wyn=0
first=bin(first)[2:]
second=bin(second)[2:]
for a in first:
iand=""
ior=""
ixor=""
for b in second:
if (a=='1' and b=='1'):
iand=iand+'1'
else:
iand=iand+'0'
if (a=='1' or b=='1'):
ior=ior+'1'
else:
ior=ior+'0'
if (a != b):
ixor=ixor+'1'
else:
ixor=ixor+'0'
wyn= wyn+(int(iand,2)+int(ior,2)+int(ixor,2))
return wyn
#These "asserts" using only for self-checking and not necessary for auto-testing
if __name__ == '__main__':
assert checkio(4, 6) == 38
assert checkio(2, 7) == 28
assert checkio(7, 2) == 18
Dec. 18, 2017