module Main where import Control.Applicative import Control.Monad dsum :: Int -> Int dsum 0 = 0 dsum n | q == 0 = r | otherwise = q + dsum r where (q, r) = n `divMod` 10 main :: IO () main = do let ms = [1 .. 12] let ds = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] happydays <- forM (zip ms ds) $ \(m, d) -> do return $ length . filter (== m) $ map dsum [1 .. d] print $ sum happydays