# frozen_string_literal: true cs = Array.new(10) (0..9).each do |i| puts i.to_s * 10 STDOUT.flush c, l = gets.split.then { |c, l| [c, l == 'unlocked'] } if l exit else cs[i] = c.to_i end end (0..9).zip(cs).map { _1.to_s * _2 }.flatten.permutation.each do |k| puts k.join STDOUT.flush _, l = gets.split.then { |c, l| [c, l == 'unlocked'] } exit if l end