require "date" module M refine Integer do def sum # to_s.chars.map(&:to_i).sum self / 10 + self % 10 end end refine Date do def happy_day? month == day.sum end end end using M puts (Date.new(2015, 1, 1)..Date.new(2015, 12, 31)).select(&:happy_day?).count # puts (Date.new(2015, 1, 1)..Date.new(2015, 12, 31)).count(&:happy_day?)