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