Guest User

Untitled

a guest
May 23rd, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.25 KB | None | 0 0
  1. str = "Hello world and hello world again!"
  2. str = str.downcase
  3. str = str.gsub!(/[0-9\W]/, "")
  4.  
  5. hash = {}
  6. hash.default = 0
  7.  
  8. str.each_char { |char|
  9. hash[char] += 1}
  10.  
  11. res = hash.sort_by{ |key,value| value}.reverse
  12.  
  13. print "Your string has this letters : #{res} "
Add Comment
Please, Sign In to add comment