@@words=[]def u(name, idx) puts "What is the #{name} letter?" letter = gets.downcase[0] @@words = @@words.find_all{|w| w.downcase[idx] == letter} puts "That narrows it down to #{@@words.length} words"enddef main File.open('/usr/share/dict/words'){|f|f.each{|l|@@words<<l.chomp}} puts "How many letters is it?" len = gets.to_i @@words = @@words.find_all{|w| w.length == len} puts "Hmm. That matches #{@@words.length} words." [[:first,0],[:last,-1]].each{|x| u x[0], x[1]} [10,@@words.length].min.times do |i| puts "Is it #{@@words[i]}?" return "HA! I told you I was smart!" if gets =~ /^y/i end return "You beat me!"endputs main