require 'date' puts (Date.new(2015)...Date.new(2016)).count { |d| d.day.to_s.chars.map(&:to_i).reduce(&:+) == d.month }