Skip to content

Instantly share code, notes, and snippets.

@jarodl
Created March 19, 2010 05:06
Show Gist options
  • Save jarodl/337252 to your computer and use it in GitHub Desktop.
Save jarodl/337252 to your computer and use it in GitHub Desktop.
hash = Hash.new
arr = [1, 1, 1, 2, 2]
arr.compact.uniq.count {|a| hash[a] = arr.count(a)}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment