Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Uncategorized category for Multiplication Table by vvm70
def checkio(first, second):
first = list(map(int, f'{first:b}'))
second = list(map(int, f'{second:b}'))
AND = sum(int(''.join(str(x & y) for y in second), 2) for x in first)
OR = sum(int(''.join(str(x | y) for y in second), 2) for x in first)
XOR = sum(int(''.join(str(x ^ y) for y in second), 2) for x in first)
return AND + OR + XOR
#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
July 29, 2020