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

commit 2b02a1a70461c85c6b823c7d88a7044c6b354b9b
parent f96694d332c1ee6522c186a9973ecfc6ede38cc0
Author: therealFIGBERT <figbertwelner@gmail.com>
Date:   Tue, 21 Jan 2020 16:41:45 -0800

Add solution to problem 4, add blank line to bottom of problem003.py

Diffstat:
Mproblem003.py | 3+--
Aproblem004.py | 14++++++++++++++
2 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/problem003.py b/problem003.py @@ -24,4 +24,4 @@ def primeFactors(num): return primes answer = max(primeFactors(600851475143)) -print("The largest prime factor of the number 600851475143 is %s" % answer) -\ No newline at end of file +print("The largest prime factor of the number 600851475143 is %s" % answer) diff --git a/problem004.py b/problem004.py @@ -0,0 +1,14 @@ +# problemName = "Largest palindrome product" +# problemNum = 4 +# solutionBy = "FIGBERT" +# language = "Python" +# dateCompleted = "21/01/2020" + +def palindromeCheck(num): + reversedNum = int(str(num)[::-1]) + if reversedNum == num: + return True + return False + +allPossibleCombos = [a*b for a in range(999, 99, -1) for b in range(999, 99, -1) if palindromeCheck(a*b)] +print("The largest palindrome made from the product of two 3-digit numbers is %s" % max(allPossibleCombos))