class HAPPY_DAY def initialize @days = { 1 => 31, 2 => 28, 3 => 31, 4 => 30, 5 => 31, 6 => 30, 7 => 31, 8 => 31, 9 => 30, 10 => 31, 11 => 30, 12 => 31 } @cnt = 0 end def happy_day (1..12).each do |month| (1..@days[month]).each do |day| d1, d2 = day.to_s.split("") d2 = "0" if d2.nil? @cnt += 1 if month == d1.to_i + d2.to_i end end @cnt end def dataoutput puts happy_day end def run dataoutput end end if $0 == __FILE__ HAPPY_DAY.new.run end