def iter(i) if i < 1000 STDOUT.puts i.to_s.rjust(3,'0') STDOUT.flush if STDIN.gets.chomp == "locked" iter(i+1) end end end iter 0