Created
October 20, 2015 16:29
-
-
Save itsbth/498daa55b08987c69218 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
from __future__ import print_function | |
# def is_palindrome(n): | |
# s = str(n) | |
# return s == s[::-1] | |
# mv = 0 | |
# for i in range(999, 100, -1): | |
# for j in range(999, 100, -1): | |
# m = i * j | |
# if m < mv: | |
# next | |
# if is_palindrome(m): | |
# mv = max(m, mv) | |
# print(mv) | |
try: | |
xrange | |
except: | |
xrange = range | |
def palindromes(): | |
for n in xrange(999, 100, -1): | |
s = str(n) | |
yield int(s + s[::-1]) | |
def main(): | |
for p in palindromes(): | |
for n in xrange(999, 100, -1): | |
div, rem = divmod(p, n) | |
if rem == 0 and div >= 100 and div < 1000: | |
return p | |
if __name__ == '__main__': | |
print(main()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment