Skip to content

Instantly share code, notes, and snippets.

@ssoroka
Created February 13, 2011 03:38
Show Gist options
  • Select an option

  • Save ssoroka/824409 to your computer and use it in GitHub Desktop.

Select an option

Save ssoroka/824409 to your computer and use it in GitHub Desktop.
spelling game in 18 lines of ruby
dictionary = File.read('/usr/share/dict/words').split("\n")
dictionary = dictionary.select { |word|
word.length > 3 && word.length < 7
}
word_picked = dictionary[rand(dictionary.size)]
system %(say "#{word_picked}")
print "Please spell the word: "
guess = gets.chomp
if guess.downcase == word_picked.downcase
puts "You spelled it right!"
else
puts "Nope, I was looking for #{word_picked}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment