(0 ... 1000).find do |n| puts "%03d" % n $stdout.flush gets.chomp == "unlocked" end