fork download
  1. def word_count(words)
  2. text = words.split
  3. text.map do |word|
  4. {word => text.select{|e| e == word}.count}
  5. end
  6. end
  7.  
  8. p word_count("Alright lets see if that works")
Success #stdin #stdout 0.06s 9648KB
stdin
Standard input is empty
stdout
[{"Alright"=>1}, {"lets"=>1}, {"see"=>1}, {"if"=>1}, {"that"=>1}, {"works"=>1}]