Skip to content

Instantly share code, notes, and snippets.

Created Nov 4, 2016
What would you like to do?
Ruby solution for CFML Slack Friday Puzzle
require 'open-uri'
require 'json'
data = JSON.load(open(""))
counts_by_user = data.each_with_object({|k,counts| counts[k['user']] += 1 }
users_by_score = counts_by_user.group_by{|k,v| v }
top_scores = users_by_score.keys.sort.reverse.first(10)
top_scores.each_with_index do |k, place|
puts "[ ##{place + 1} @ #{k}k ]: #{users_by_score[k].map{|u| u[0] }.join(', ')}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment