Finding the smallest common denominator
<p>I have the following problem. I have a arrays of <code>L</code> binary entries.(<code>L</code> is usually between 2 and 8 if it is of interest.) All possible combinations do exist. So there are <code>2^L</code> arrays in one realisation. Now each combination will get randomly a fitness value assigned. The fitness value is also either <code>1</code> or <code>0</code>. Now for example it could be, that the following arrays have fitness value <code>0</code>:</p>

<pre><code>1000
1010
1100
1001
1011
</code></pre>

<p>Then it is true, that all arrays with a <code>10__</code> are zero and all with <code>1_00</code>. This is actually my problem. I need an algorithm which find these similarities and sort them for their rank. Like <code>10__</code> is of rank <code>2</code> and <code>1_00</code> is of rank <code>3</code>. It is most of the time possible to define all arrays with zero fitness either with a small number of low ranks or with many high ranks. So my output must be ordered and I need to know how many I have of each rank. I can imagine that this is a known problem and there is already a solution?  I hope you can help :) </p>

<p>As already mentioned, this is a combinational logic minimization problem.</p>

<p>The algorithm typically used is Quine-Mccluskey and somebody has already asked for and posted a Python implementation:</p>

<p><a href="http://stackoverflow.com/questions/7537125/quine-mccluskey-algorithm-in-python">Quine-McCluskey algorithm in Python</a></p>

python