$>.sync = true ans = (1..10**9).bsearch{|i| puts"? #{i}" gets>?1 } puts"! #{ans}"