Merge pull request #25 from rtoal/master

A first try at a Ruby golf
This commit is contained in:
crista
2015-01-31 16:09:13 -08:00

6
06-code-golf/tf-06.rb Executable file
View File

@@ -0,0 +1,6 @@
#!/usr/bin/env ruby
require 'set'
stops = ((IO.read '../stop_words.txt').split ',').to_set
ARGF.read.downcase.scan(/[a-z]{2,}/).each_with_object(Hash.new 0){|w,c|c[w]+=1 if not stops.member? w}.sort_by{|w,c|-c}[0,25].each{|w,c|puts "#{w} - #{c}"}