-- Problems/Problem055.hs
module Problems.Problem055 (p55) where

main = print p55

p55 :: Int
p55 = length $ filter (not . (flip isLynchel) 0) [1..9999]

isLynchel :: Integer -> Int -> Bool
isLynchel num i 
    | i >= 50 = False
    | isPalindrom nextNum = True
    | otherwise = isLynchel nextNum (i + 1)
    where nextNum = num + (reverseInt num)

isPalindrom :: Integer -> Bool
isPalindrom num = num == (reverseInt num)

reverseInt :: Integer -> Integer
reverseInt = read . reverse . show
