require 'date' a = Date.new(2015, 1, 1) b = Date.new(2015, 12, 31) def happy_days(a, b) (a..b).count { |c| c.month == c.day.to_s.split('').map(&:to_i).inject(:+) } end puts happy_days(a, b)