require 'date' a = (Date.parse('2015-01-01') .. Date.parse('2015-12-31')).select do |d| d.month == d.day.to_s.split('').map(&:to_i).inject(&:+) end.size puts a