YAPC::EU 2018 Glasgow Update!
This commit is contained in:
parent
22f33d4004
commit
4e2d22a71d
1170 changed files with 15042 additions and 3047 deletions
|
|
@ -2,22 +2,14 @@ require 'date'
|
|||
# The only case where the month has 5 weekends is when the last day
|
||||
# of the month falls on a Sunday and the month has 31 days.
|
||||
|
||||
dates = []
|
||||
1900.upto(2100) do |year|
|
||||
1.upto(12) do |month|
|
||||
d = Date.new(year, month, -1) # -1 is last day of month
|
||||
dates << d if d.sunday? && d.day == 31
|
||||
end
|
||||
end
|
||||
LONG_MONTHS = [1,3,5,7,8,10,12]
|
||||
YEARS = (1900..2100).to_a
|
||||
|
||||
dates = YEARS.product(LONG_MONTHS).map{|y, m| Date.new(y,m,31)}.select(&:sunday?)
|
||||
years_4w = YEARS - dates.map(&:year)
|
||||
|
||||
puts "There are #{dates.size} months with 5 weekends from 1900 to 2100:"
|
||||
puts dates.first(5).map { |d| d.strftime("%b %Y") }
|
||||
puts "..."
|
||||
puts dates.last(5).map { |d| d.strftime("%b %Y") }
|
||||
|
||||
years_with_5w = dates.map(&:year)
|
||||
|
||||
years = (1900..2100).to_a - years_with_5w
|
||||
|
||||
puts "There are #{years.size} years without months with 5 weekends:"
|
||||
puts years.join(", ")
|
||||
puts dates.first(5).map {|d| d.strftime("%b %Y") }, "..."
|
||||
puts dates.last(5).map {|d| d.strftime("%b %Y") }
|
||||
puts "There are #{years_4w.size} years without months with 5 weekends:"
|
||||
puts years_4w.join(", ")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue