class HappyDay require "date" attr_reader :count def initialize @count = 0 end def happycheck(m, d) ary = Array.new ary = d.to_s.split("") if m == ary[0].to_i + ary[1].to_i @count += 1 end return @count end end d = Date.new(2015,1,1) chk = HappyDay.new chk.happycheck(d.month, d.day) 364.times do d += 1 chk.happycheck(d.month, d.day) end puts chk.count