Created
January 1, 2019 23:17
-
-
Save kenprice/d171bd9ff61b2ff1204369b722a09d23 to your computer and use it in GitHub Desktop.
Project Euler Problem 4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Data.List | |
products :: [Int] | |
products = reverse (Data.List.sort [x*y | x<-[100..999], y<-[100..999]]) | |
isPalindrome :: Int -> Bool | |
isPalindrome x = (read (reverse (show x)) :: Int) == x | |
getLargestPalindrome :: [Int] -> Int | |
getLargestPalindrome xs = | |
if isPalindrome (head xs) | |
then (head xs) | |
else getLargestPalindrome(tail xs) | |
main :: IO() | |
main = putStrLn (show (getLargestPalindrome products)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment