Skip to content

Instantly share code, notes, and snippets.

@shieldsd
Created April 3, 2012 09:18
Show Gist options
  • Save shieldsd/2290613 to your computer and use it in GitHub Desktop.
Save shieldsd/2290613 to your computer and use it in GitHub Desktop.
Project Euler #36
def palindrome(s):
return s == s[::-1]
def d2b(n):
s = ''
while n:
if n & 1:
s = '1' + s
else:
s = '0' + s
n = (n >> 1)
return s
print sum(i for i in xrange(1000000)
if palindrome(str(i))
and palindrome(d2b(i)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment