Skip to content

Instantly share code, notes, and snippets.

@codatory
Created June 26, 2013 15:13
Show Gist options
  • Save codatory/5868271 to your computer and use it in GitHub Desktop.
Save codatory/5868271 to your computer and use it in GitHub Desktop.
Decision making made easy
def make_decision(&block)
raw = (0..9).map{ block.call }
freq = raw.inject(Hash.new(0)) { |h,v| h[v] += 1; h }
raw.sort_by { |v| freq[v] }.last
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment