Created
June 24, 2011 18:42
-
-
Save rainzoo/1045398 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""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]]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""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