1
0
Fork 0

Euler question 4 - add in question statement,

and solve the problem actually be asked lol
main
Bill Ewanick 2023-09-19 15:35:57 -04:00
parent a6aab6fa2d
commit 0ab298bb66
1 changed files with 11 additions and 2 deletions

View File

@ -1,10 +1,19 @@
-- https://projecteuler.net/problem=4
{-
https://projecteuler.net/problem=4
A palindromic number reads the same both ways.
The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 x 99.
Find the largest palindrome made from the product of two 3-digit numbers.
-}
import Debug.Trace (trace)
twoDigitProducts :: [Integer]
twoDigitProducts = [ n*m | n <- [10..99], m <- [n..99] ]
threeDigitProducts :: [Integer]
threeDigitProducts = [ n*m | n <- [100..999], m <- [n..999] ]
isPalindrome :: Integer -> Bool
isPalindrome n = all (== True) $ zipWith (==) half half'
where
@ -15,7 +24,7 @@ isPalindrome n = all (== True) $ zipWith (==) half half'
-- n' = trace (show n) $ show n
solve :: Integer
solve = maximum $ filter isPalindrome twoDigitProducts
solve = maximum $ filter isPalindrome threeDigitProducts
main :: IO ()
main = print solve