require 'date' a = Date.new(2015, 1, 1) b = Date.new(2015, 12, 31) count = 0 for i in a..b f_digit = i.day % 10 s_digit = i.day / 10 sum = f_digit + s_digit if i.month == sum count += 1 end end puts count