Skip to content

Instantly share code, notes, and snippets.

@JacksonGariety
Last active October 21, 2016 05:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JacksonGariety/21441e8c397a2a44580b0e75a8c6be8c to your computer and use it in GitHub Desktop.
Save JacksonGariety/21441e8c397a2a44580b0e75a8c6be8c to your computer and use it in GitHub Desktop.
import Data.List
main = print $ largestPalindrome 3
isPalindrome :: Integer -> Bool
isPalindrome n =
let s = show n
in reverse s == s
largestPalindrome :: Integer -> Integer
largestPalindrome e = last . sort $ filter isPalindrome [x * y | x <- [100..10^e], y <- [100..10^e], y >= x]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment