type Odds = [Odd] data Odd = One | Three | Five | Seven | Nine deriving (Eq, Enum, Bounded) one :: Odds one = [minBound] instance Show Odd where show One = "1" show Three = "3" show Five = "5" show Seven = "7" show Nine = "9" showOdds :: Odds -> String showOdds = concatMap show inc :: Odds -> Odds inc xs = case foldr f ([], True) xs of (acc, True) -> minBound : acc (acc, _) -> acc where f x (acc, True) | x == maxBound = (minBound : acc, True) | otherwise = (succ x : acc, False) f x (acc, _) = (x : acc, False) main :: IO () main = print . takeWhile (<=1000) . map (read . showOdds) $ iterate inc one