I am up to question 36 , and I thought it would be easy. As usual, I'm apparently mistaken. I am trying to do this in Python (because I do not know Python). My code is below. As a conclusion, I get 19, which seems to be wrong. I do not see what I am missing. Any suggestions (without correcting the code) will be appreciated. I don't need the right answer or code (or even the exact location of my error) - just a hint to lead me in the right direction.
def isPolynomial(number):
if(str(number) == str(number)[::-1]):
return True
else:
return False
def isBinaryPolynomial(number):
binNum = bin(number)
binStr = str(binNum)[2:]
revbinStr = binStr[::-1]
if(binStr == revbinStr):
return True
else:
return False
count = 0
for i in range(1, 1000001):
if isPolynomial(i):
if isBinaryPolynomial(i):
count += 1
print count
source
share