Project Euler Problem 019
import Data.List -- 0:monday,1:tuesday,2:wednesday,3:thursday,4:friday,5:saturday,6:sunday days :: [Integer] days = concatMap (\x -> [31,28+leap x,31,30,31,30,31,31,30,31,30,31]) [1901..2000::Integer] -- 365`rem`7が1901/01/01の曜日。init daysで2001/01/01の曜日を取り除く daysl :: [Integer] daysl = scanl (\a x -> (a+x)`rem`7) (365`rem`7) $ init days leap :: (Integral a, Num a1) => a -> a1 leap n = if rem n 4 == 0 && rem n 100 /= 0 && rem n 400 == 0 then 1 else 0 ans1 :: Int ans1 = length $ filter (==6) daysl --171 main :: IO () main = print ans1