days = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] count = 0 (0..11).each { |n| j = 0 while j < days[n] sum = j / 10 + j % 10 count += 1 if sum == n + 1 j += 1 end } puts count