# Project Euler Problem 19

Thanks to .NET libraries solution to Project Euler Problem 19 is as easy as 1-2-3, where:

- is building a list of all dates that were 1st of the month

during 20th century - is filtering out all, but Sundays from them
- is counting the leftovers

open System let problem019 () = Seq.unfold (fun x -> if x > DateTime (2000,12,31) then None else Some (x, x.AddMonths(1))) (DateTime(1901,1,1)) |> Seq.filter (fun x -> x.DayOfWeek = DayOfWeek.Sunday) |> Seq.length

I was so impressed with the power of .NET DateTime type that couldn’t resist posting my solution at F# Snippets.

Advertisements

Leave a Comment