max = 999 (0..max).each do |i| puts i.to_s.rjust(3,"0") STDOUT.flush break if gets.chomp == "unlocked" end