Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Multiplication Table by toito
def checkio(first, second):
sum, f, s = 0, format(first, "b"), format(second, "b")
for i in f:
sum += pow(2, len(s)) - 1 if i == "1" else second
return sum * 2 #"or" == "and" + "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
April 13, 2018