codingtests/ProjectEuler/019/solve.rb

9 lines
177 B
Ruby
Raw Normal View History

2012-03-09 12:48:12 +00:00
require "date"
sundays = 0
(1901..2000).each do |year|
(1..12).each do |month|
dt = Date.new(year,month,1)
sundays += (dt.wday == 0) ? 1 : 0
end
end
puts sundays