def solution(x: int, y: int) -> bool:
return len([i for i in [i_x for i_x in range(len(bin(x))) if bin(x)[-i_x] == '1'] if
i in [i_y for i_y in range(len(bin(x))) if bin(y)[-i_y] == '1']]) >= 2
assert solution(7, 10) is False
assert solution(7, 15) is True
assert solution(1, 2) is False
def solution(x: int, y: int):
x_len = len(bin(x))
num = 0
for i in range(0, x_len):
binary_system_x = bin(x)[i]
binary_system_y = bin(y)[i]
if binary_system_x == binary_system_y and binary_system_x == 1 and binary_system_y == 1:
num += 1
if num >= 2:
return True
else:
return False
def solution(x: int, y: int) -> bool:
countx = 0
count = 0
for i in str(bin(x))[::-1]:
countx += 1
county = 0
if i == 'b': break
for j in str(bin(y))[::-1]:
county += 1
if county == countx:
if j == i:
count += 1
if count >= 2:
return True
else:
return False
if __name__ == '__main__':
assert solution(7, 10) is False
assert solution(7, 15) is True
assert solution(1, 2) is False
def solution(x: int, y:int) -> bool:
nor_b = str(format(x^y,'b'))
max_b = str(format(x,'b')) if x>y else str(format(y,'b'))
i = 0
num = 0
while i<len(nor_b):
index = nor_b.find('0',i)
if index == -1: break
if index < len(max_b) and max_b[index] == '1':
num += 1
i = index+1
return num>=2