calendar2015 :: [(Int, Int)] calendar2015 = [(1,31), (2,28), (3,31), (4,30), (5,31), (6,30), (7,31), (8,31), (9,30), (10,31), (11,30), (12,31)] happyDay :: Int -> Int -> Bool happyDay m d | m == d_10 + d_01 = True | otherwise = False where d_10 = floor $ (fromIntegral (d :: Int)) / 10.0 d_01 = d - d_10 * 10 happyDayCounter :: [(Int, Int)] -> Int happyDayCounter [] = 0 happyDayCounter (c:cs) = do let m = fst c d = snd c days = [1..d] happyDayCounter' m days + happyDayCounter cs where happyDayCounter' :: Int -> [Int] -> Int happyDayCounter' _ [] = 0 happyDayCounter' m (d:ds) -- = cnt + happyDayCounter' m ds | happyDay m d == True = happyDayCounter' m ds + 1 | otherwise = happyDayCounter' m ds main = print $ happyDayCounter calendar2015