Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Count digits

text = "123456789112777"
count = [0] * 10

text.each_char { |chr|
  count[chr.to_i] += 1
}

count.each_with_index { |value, idx|
  puts "#{idx} #{value}"
}