Created
March 21, 2010 17:32
-
-
Save hroi/339444 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ; 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