Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
# 30 mar 2012
final = {:draw => [46, 23, 38, 4, 2], :mega => 23}
scores = [
{:draw => [0,0,0,0,0], :mega => 0},
{:draw => [0,0,0,0,0], :mega => 0},
{:draw => [0,0,0,0,0], :mega => 0},
{:draw => [0,0,0,0,0], :mega => 0},
{:draw => [0,0,0,0,0], :mega => 0},
# Add More
]
results = []
scores.each do |score|
d = score[:draw].reject{|i| !final[:draw].include?(i)}.length
m = (score[:mega] == final[:mega] ? 1 : 0)
results.push({:score => score, :draw => d, :mega => m})
end
puts "\n\n"
results.sort{|a,b| (b[:draw]+b[:mega]) <=> (a[:draw]+a[:mega])}.each do |r|
puts "#{"#{r[:draw]} #{"+MEGA" if r[:mega] > 0}".ljust(10)}#{r[:score][:draw].join('-')} +#{r[:score][:mega]}"
end
puts "\n\n"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.