c = 0 [31,28,31,30,31,30,31,31,30,31,30,31].each_with_index{|t,d| t.times do|i| if d+1==(i+1).to_s.chars.map(&:to_i).sum c+=1 end end } p c