Skip to content

Instantly share code, notes, and snippets.

@seungjin
Created November 15, 2011 23:35
Show Gist options
  • Select an option

  • Save seungjin/1368753 to your computer and use it in GitHub Desktop.

Select an option

Save seungjin/1368753 to your computer and use it in GitHub Desktop.
name_jar = [
'calvin',
'tom',
'tomase',
'justin',
'gary',
'sam',
'adam',
'ryan',
'erik',
'garry',
'lucas',
'leon',
'luka/loca',
'paul',
'jonas',
'max',
'Louis'
]
#puts name_jar[rand(name_jar.length-1)]
g = Hash.new
(1..100000000).each do |i|
name = [name_jar[rand(name_jar.length-1)]]
if g.has_key?(name) == false
g[name] = 1
else
g[name] = g.values_at(name)[0] + 1
#puts g.values_at(name)[0] + 1
end
end
g.sort_by {|key,value| value}
g.each do |key,value|
puts "#{key} \t : \t #{value}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment