Created
June 26, 2013 16:50
-
-
Save danielevans/5869148 to your computer and use it in GitHub Desktop.
Counting Sundays
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
require 'date' | |
sundays = (1901..2000).reduce(0) do |memo, year| | |
memo + (1..12).count do |month| | |
Date.new(year, month, 1).sunday? | |
end | |
end | |
puts sundays |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment