Skip to content

Instantly share code, notes, and snippets.

@nesquena
Created May 31, 2009 05:53
Show Gist options
  • Save nesquena/120783 to your computer and use it in GitHub Desktop.
Save nesquena/120783 to your computer and use it in GitHub Desktop.
# Reia script
module Sundays
def first_day_is_sunday(y, m)
calendar::day_of_the_week(y, m, 1) == 7
end
def count_valid_months
[ 1 | y in 1901..2000, m in 1..12, first_day_is_sunday(y,m) ].size()
end
end
puts(Sundays.count_valid_months()) # => 171
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment