Created
October 31, 2014 09:46
-
-
Save diasjorge/16b529bd80f56123d9ad to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'pp' | |
class Array | |
def average | |
inject(0.0) { |sum, e| sum + e } / length | |
end | |
end | |
res = {} | |
['naoise','alejandro','erick'].each do |name| | |
res[name] = 1_000_000.times.map { rand }.average | |
end | |
winner = res.sort_by { |k,v| v }.last.first | |
puts "And the winner is #{winner}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment