Skip to content

Instantly share code, notes, and snippets.

@hroi
Created March 21, 2010 17:32
Show Gist options
  • Select an option

  • Save hroi/339444 to your computer and use it in GitHub Desktop.

Select an option

Save hroi/339444 to your computer and use it in GitHub Desktop.
; Problem 19
; How many Sundays fell on the first of the month during the twentieth
; century (1 Jan 1901 to 31 Dec 2000)?
(count
(for [year (range 1 101) month (range 0 12)
:let [day (.getDay (doto (java.util.Date.) (.setYear year)
(.setMonth month) (.setDate 1) (.getDay)))]
:when (= day 0)]
[year, month]))
; => 171
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment