# frozen_string_literal: true def unlocked? gets.split.then { |c, l| [c.to_i, l == 'unlocked'] } end cs = Array.new(10) (0..9).each do |i| puts i.to_s * 10 STDOUT.flush c, l = unlocked? if l exit else cs[i] = c.to_i end end es = Array.new(10) (0..9).zip(cs).map do |i, c| (0..9).to_a.combination(c).each do |j| ds = Array.new(10, '*') j.each do |k| ds[k] = i end puts ds.join STDOUT.flush d, l = unlocked? if l exit else if c == d es[i] = j break end end end end xs = Array.new(10) es.each_with_index do |e, j| e.each do |i| xs[i] = j end end puts xs.join