Skip to content

Instantly share code, notes, and snippets.

@jonatas
Created March 16, 2016 23:09
Show Gist options
  • Select an option

  • Save jonatas/c1b83d2a5bf8a6dc7f1b to your computer and use it in GitHub Desktop.

Select an option

Save jonatas/c1b83d2a5bf8a6dc7f1b to your computer and use it in GitHub Desktop.
dictionary = Hash.new { |hash, key| hash[key] = 0 }
Dir["*.md"].each do |filename|
File.readlines(filename).each do |line|
line.split(" ").each do |word|
dictionary[word] += 1 if word.length > 3
end
end
end
dictionary.reject! { |_,counter| counter < 10 }
p dictionary.sort_by{|k,v|v}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment