Created
February 13, 2011 03:38
-
-
Save ssoroka/824409 to your computer and use it in GitHub Desktop.
spelling game in 18 lines of ruby
This file contains hidden or 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
| 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