Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jul 11th, 2012  |  syntax: None  |  size: 0.51 KB  |  hits: 21  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. def pallin(a, b):
  2.     c = a * b
  3.     if str(c) == str(c)[::-1]:
  4.         pal_list.append([x,y,c])
  5.  
  6. pal_list = []
  7. pal_start = 100
  8. pal_end = 1000
  9. for x in range(pal_end, pal_start, -1):
  10.     for y in range(x, pal_start, -1):
  11.         pallin(x,y)
  12.  
  13. pal_list.sort(key=lambda f: f[2], reverse = True)
  14. if len(pal_list) > 0:
  15.     print(len(pal_list)," Palindrome Found! from ",pal_start," to ",pal_end)
  16.     print("The Top 3: ")
  17.     for i in pal_list[0:3]:
  18.         print("Palindrome: ",i[2]," at: ",i[0]," and ",i[1])