(0..9).inject([p]*10){|a,i| (0..9).map{|j| a[i]=j puts s = a.map{|n|n||0}*"" exit if 10 == n = gets.to_i [n, a.dup] }.max[1] }