Skip to content

Instantly share code, notes, and snippets.

/ruby.rb Secret

Created May 28, 2015 08:22
Show Gist options
  • Save anonymous/df79ec84f6543ab5ddd4 to your computer and use it in GitHub Desktop.
Save anonymous/df79ec84f6543ab5ddd4 to your computer and use it in GitHub Desktop.
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
@marcelvanworkum
Copy link

homeworkYAY.rb:7:in block in <main>': undefined methodget_guessing_word' for main:Object (NoMethodError)
from homeworkYAY.rb:5:in loop' from homeworkYAY.rb:5:in

'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment