s = '0000000000' tmp = 0 10.times{|k| 0.upto(9){|i| s[9 - k] = i.to_s puts s STDOUT.flush x,judge = gets.chomp.split x = x.to_i if judge == 'unlocked' exit end if tmp < x tmp = x break end } }