A first try at a Ruby golf
This commit is contained in:
6
06-code-golf/tf-06.rb
Executable file
6
06-code-golf/tf-06.rb
Executable 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}"}
|
||||||
|
|
||||||
Reference in New Issue
Block a user