def expand_bin(bin_number) :
i = 0
while len(bin_number) > 2**(i+1) - 1 :
i += 1
return '0'*(2**(i+1) - 1 - len(bin_number)) + bin_number
def possiblity_check(bin_number) :
center = len(bin_number) // 2
if len(bin_number) == 1 :
return True
elif bin_number[center] == '0' :
return not ('1' in bin_number[:center] or '1' in bin_number[center + 1:])
else:
return possiblity_check(bin_number[:center]) and possiblity_check(bin_number[center + 1:])
def solution(numbers):
answer = []
for number in numbers :
bin_number = str(bin(number))[2:]
bin_number = expand_bin(bin_number)
answer.append(possiblity_check(bin_number)*1)
return answer