Skip to content

Instantly share code, notes, and snippets.

Created December 6, 2015 09:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/0feee55bcb18bbe9dfda to your computer and use it in GitHub Desktop.
Save anonymous/0feee55bcb18bbe9dfda to your computer and use it in GitHub Desktop.
puts "Your text: "
text = gets.chomp
words = text.split(" ")
frequencies = Hash.new(0)
words.each { |i| frequencies[i] += 1 }
frequencies = frequencies.sort_by { |i,x| x }
frequencies.reverse!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment