Skip to content Skip to sidebar Skip to footer

Project Euler Question 36

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 gett

Solution 1:

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!

Solution 2:

From http://projecteuler.net/index.php?section=problems&id=36

Find the sum of all numbers, less than one million, which are palindromic in base 10 and base 2.

Solution 3:

The question asks for the sum of the numbers, not the count. Also this does not make a difference in the answer you get, but the word is "Palindrome", not "Polynomial"

Solution 4:

# -*- coding: utf-8 -*-
"""
@author: neo
"""
def bin(x):
    result = ''
    x = int(x)
    while x > 0:
        mod = x % 2
        x /= 2
        result = str(mod) + result
    return result
print sum(i for i in xrange(1,1000001)\
    if str(i)==str(i)[::-1] and str(bin(i))==str(bin(i))[::-1])

Post a Comment for "Project Euler Question 36"