puts (0..2000).bsearch { |x| puts "? #{x}"; STDOUT.flush a = read_line puts "? #{x + 1}" b = read_line; STDOUT.flush a == b == "out" }.try(&.pred)