ans = [*0..9] b = ans + [0,1,2] puts "0 1 2 3" STDOUT.flush x,y = gets.split.map(&:to_i) tmp = y 1.upto(9){|i| puts b[i,4].join(' ') STDOUT.flush x,y = gets.split.map(&:to_i) if tmp > y ans.delete(b[i]) ans.delete(b[i + 3]) elsif tmp < y ans.delete(b[i]) end tmp = y if ans.size == 4 break end } ans.permutation(4).to_a.each{|a| puts a.join(' ') STDOUT.flush x,y = gets.split.map(&:to_i) if x == 4 break end }