Code optimize

- Initialize hash with '0'
- Use range ('0'..'9') instead of regex for the same
- Increase readability by using 'when' 'then' statement
- change method name 'count_by_type' -> 'count_chars_by_type'