Exercise: count digits in a file

Given a file like this, that has rows of numbers in it without anything, but a single space in between the numbers. Our task is to count how many times each digit appears.

examples/data/count_digits.txt

23 34 9512341
3 34 2452345 5353 67 22
42136357013412
42 5 65 64 

Our expected output looks like this:

0 1
1 5
2 9
3 11
4 9
5 8
6 4
7 2
8 0
9 1

Tools for Perl 5

Tools for Ruby

Solutions