Created
December 12, 2013 19:10
-
-
Save domgetter/7933643 to your computer and use it in GitHub Desktop.
Jotto full code to spec
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
print "Number of letters? " | |
input = gets.chomp.to_i | |
class String | |
def uniquely_lettered? | |
self.scan(/./).uniq.length == self.length | |
end | |
end | |
filename = "C:/Users/Godd2/ruby/Jotto/jotto_words.txt" | |
words = File.open(filename, 'r') {|f| f.read.split("\n")} | |
words.delete_if {|word| (word.length != input) || !(word.uniquely_lettered?) } | |
puts words.sample |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment