Skip to content

Instantly share code, notes, and snippets.

@rainzoo
Created June 24, 2011 18:42
Show Gist options
  • Save rainzoo/1045398 to your computer and use it in GitHub Desktop.
Save rainzoo/1045398 to your computer and use it in GitHub Desktop.
"""Find the largest palindrome made from the product of two 3-digit numbers."""
from itertools import combinations as cnr
print max([ x*y for (x,y) in cnr(range(100,999),2) if str(x*y) == str(x*y)[::-1]])
"""Find the largest palindrome made from the product of two 3-digit numbers."""
from itertools import combinations as cnr
largest = 0
for (x,y) in cnr(range(100,999),2):
s = x*y
if (str(s) == str(s)[::-1]):
largest = max([largest,s])
print largest
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment