-
-
Save anonymous/df79ec84f6543ab5ddd4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'net/http' | |
File.write("words.txt", Net::HTTP.get(URI("http://seriousorange.com/words.txt"))) | |
loop do | |
file = File.read("words.txt").split | |
word = get_guessing_word(file) | |
puts word | |
end | |
def get_guessing_word(file) | |
words = file.select {|word| word.length == 5 or word.length == 6} | |
hash = Hash[words.uniq.map { |word| [word, words.count(word)] }] | |
common_words = words.sort_by { |word| hash[word] } | |
return common_words[0..1999].sample | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
homeworkYAY.rb:7:in
'block in <main>': undefined method
get_guessing_word' for main:Object (NoMethodError)from homeworkYAY.rb:5:in
loop' from homeworkYAY.rb:5:in