$stdout.sync = true for n in 0..999 do puts "%03d" % n res = gets break if res == "unlocked" end