Useful trick, if you have a hash like this:
a = {1 => [2,3,4], 2 => [3,4,5], 3 => [4,5,6,7]}
and you would like to get to a hash containing the same keys, but the count of the values:
a = {1 => 3, 2 => 3, 3 => 4}
a.merge(a) {|k,v| v.count }
hash#merge takes the following params:
merge(other_hash){|key, oldval, newval| block} → new_hash