Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Multiplication Table by martin_b
def checkio(first, second):
ones = (1 << second.bit_length()) - 1
r = 0
while first > 0:
op = ones if first & 1 else 0
r += (second & op) + (second | op) + (second ^ op)
first >>= 1
return r
#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
Jan. 30, 2016