Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Project Euler question 36

Tags:

python

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
like image 547
Matt M Avatar asked Sep 02 '25 05:09

Matt M


1 Answers

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!

like image 148
RoundTower Avatar answered Sep 04 '25 20:09

RoundTower