Skip to content

Instantly share code, notes, and snippets.

@itsbth
Created October 20, 2015 16:29
Show Gist options
  • Save itsbth/498daa55b08987c69218 to your computer and use it in GitHub Desktop.
Save itsbth/498daa55b08987c69218 to your computer and use it in GitHub Desktop.
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