project-euler-100

[RADIOACTIVE] solutions to the first 100 challenges of project euler
git clone git://git.figbert.com/project-euler-100.git
Log | Files | Refs | README

problem004.py (450B)


      1 # problemName = "Largest palindrome product"
      2 # problemNum = 4
      3 # solutionBy = "FIGBERT"
      4 # language = "Python"
      5 # dateCompleted = "21/01/2020"
      6 
      7 if __name__ == "__main__":
      8     all_possible_combos = [
      9         a*b for a in range(999, 99, -1) for b in range(999, 99, -1) 
     10         if int(str(a*b)[::-1]) == a*b
     11     ]
     12     print((
     13         "The largest palindrome made from the product of two 3-digit "
     14         "numbers is %s" % max(all_possible_combos)
     15     ))