Skip to content

Instantly share code, notes, and snippets.

@hatashiro
Created April 13, 2012 14:09
Show Gist options
  • Save hatashiro/2377142 to your computer and use it in GitHub Desktop.
Save hatashiro/2377142 to your computer and use it in GitHub Desktop.
Projecteuler #4
def isPalindrome(int):
intstr = str(int)
length = len(intstr)
if length%2:
mid = length / 2
pre = intstr[0:mid]
suf = intstr[mid+1:length]
else:
mid = length / 2
pre = intstr[0:mid]
suf = intstr[mid:length]
return pre[::-1] == suf
max = 0
for i in range(100, 1000):
for j in range(100, 1000):
if i*j > max and isPalindrome(i*j):
max = i*j
print max
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment