require 'date' count = 0 (1901..2000).each do |year| (1..12).each do |month| date = Date.civil(year, month, 1) count += 1 if date.cwday == 7 # 7 = Sunday end end puts count