Skip to content

Instantly share code, notes, and snippets.

@aberant
Forked from thumblemonks/team-votes.rb
Created March 22, 2010 18:29
Show Gist options
  • Save aberant/340356 to your computer and use it in GitHub Desktop.
Save aberant/340356 to your computer and use it in GitHub Desktop.
require 'pp'
votes = {
"gus" => ["Colonel Panic", "Cigar Heroes"],
"shinji" => ["Bomb Squad","Taco Town"],
"nawara" => ["Colonel Panic", "Taco Town", "Danger!! Death Ray"],
"dodos" => [],
"richie" => [],
"colin" => ["Colonel Panic", "Taco Town"],
"joey" => ["Danger!! Death Ray", "Bomb Squad"]
}
# In a tie, Shinji rules them all
pp votes.values.flatten.inject(Hash.new(0)) {|counter, name| counter[name] += 1; counter }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment