Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Only OOP solution in Clear category for Multiplication Table by swagg010164
class BinNumber:
def __init__(self, value):
self.value = bin(value)[2:]
def __and__(self, other):
return sum(
int("".join('1' if char1 == char2 == '1' else '0' for char2 in other.value), 2) for char1 in self.value)
def __xor__(self, other):
return sum(
int("".join('1' if char1 != char2 else '0' for char2 in other.value), 2) for char1 in self.value)
def __or__(self, other):
return sum(
int("".join('1' if char1 == '1' or char2 == '1' else '0' for char2 in other.value), 2) for char1 in
self.value)
def checkio(first, second):
a, b = BinNumber(first), BinNumber(second)
return (a & b) + (a | b) + (a ^ b)
Aug. 12, 2020
Comments: