ans = [] 0.upto(9){|i| puts "#{i} #{i} #{i} #{i}" STDOUT.flush x,y = gets.split.map(&:to_i) if y != 0 ans.push(i) 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 }