Skip to content

Instantly share code, notes, and snippets.

@domgetter
Created December 12, 2013 19:10
Show Gist options
  • Save domgetter/7933643 to your computer and use it in GitHub Desktop.
Save domgetter/7933643 to your computer and use it in GitHub Desktop.
Jotto full code to spec
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