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