I'm up to question 36 and I thought this would be simple. As usual, I am apparently wrong. I'm trying to do this in Python (because I don't know Python). My code is below. I'm getting 19 as the output, which is apparently incorrect. I don't see what I'm missing. Any suggestions (without correcting the code) would be appreciated. I don't want the correct answer or the code (or even an exact location of my error) - just a hint to get 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
It looks like your code is correct, but you need to read carefully what it asks you to submit as the answer. I can't be any more specific without giving it away!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With