#!/usr/local/bin/ruby freq=Hash.new(0) while s=gets for ch in s.chomp!.split(//) freq[ch] += 1 end end puts "---+--------" for ch, in freq.keys.sort{|x, y| freq[y] <=> freq[x]} if /[a-z]/ =~ ch printf(" %s | %3d\n", ch, freq[ch]) end end puts "---+--------"