class EXPERT
    
    FIND_CHAIN_FOR_POS_FILTER_PIPELINE = 
      [ 
        :no_filter,
        :filter_by_etkz_e,
        :filter_chain_in_chain,
      ].each
    
    def find_chain_for_pos(sw_lines_for_module)

      br = '4711'

      FIND_CHAIN_FOR_POS_FILTER_PIPELINE.rewind        

      begin
        
        while true
          
          filter_method_symb = FIND_CHAIN_FOR_POS_FILTER_PIPELINE.next
          
          sw_lines_for_module = NVP.send(filter_method_symb, br, sw_lines_for_module) 
          
          # LOG.trace { "SW Lines left after filter #{filter_method_symb}:\n#{SwRec.show_array(sw_lines_for_module)}"}
          
        end
        
      rescue StopIteration
        
        puts "done...."
        # LOG.trace "Could not find unique GRPID"
        
      end
      
                                                                                          
      nil                                                                                             
      
    end
end

class Cnt
  def initalize(n)
    @c=n
  end
  def decr
    @c -= 1
  end
  def to_s
    @c.to_s
  end
end

module NVP
  extend self
  def no_filter(b,a)
    [[a.size, b.nil?]] * (a.size)
  end
  def filter_by_etkz_e(x,y)
    no_filter(x,y)
  end
  def filter_chain_in_chain(x,y)
    filter_by_etkz_e(x,y)
  end
  def mu?(cn)
    cn.decr > 0
  end
end

newc = (ARGV[0]||1).to_i

c = EXPERT.new

newc.times do |cnt| 
  # puts "#{cnt} out of #{newc}"
  puts cnt
  c.find_chain_for_pos(%w(a b c d e))  
end
