Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
THE NIGHTMARE SOLUTION solution in Clear category for Multiplication Table by milanandreewdev
def checkio(first, second):
firstbin = list(bin(first))[2:]
secondbin = list(bin(second))[2:]
print(firstbin,secondbin)
def sumthem(listi):
counter = 0
stri = ''
result = []
for i in listi:
stri += str(i)
counter +=1
if counter == len(secondbin):
#print stri
result.append(int(stri,2))
stri = ""
counter = 0
return sum(result)
listAND = [int(i) & int(y) for i in firstbin for y in secondbin]
listOR = [int(i) | int(y) for i in firstbin for y in secondbin]
listXOR = [int(i) ^ int(y) for i in firstbin for y in secondbin]
return sumthem(listAND)+sumthem(listOR)+sumthem(listXOR)
# 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
Oct. 25, 2016