All possibilities permutations of 0 and 1
<p>I want to list all possible permutations of 0 and 1 six times for probability reasons.</p>

<p>I started out like this, thinking, it was a piece of cake; until all combinations are listed the code should keep on randomising the values.
However once 0 and 1 are in the list it stops, i thought "for range in 6" would give something like this:</p>

<p><code>"0,0,0,0,0,0"</code> (which is a possibility of 0 and 1)</p>

<p><code>"1,1,1,1,1,1"</code> (which also is a possibility of 0 and 1)</p>

<p>My current output is "0, 1"</p>

<p>How can I group the items together of pieces of 6 and make the program keep filling values up unless a combination is already in my list?<br>
I know there are 64 combinations altogether because of 2^6.</p>

<pre><code>import math
import random

    a = 63;
    b = 1;
    sequences = [];
    while (b &lt; a):
        for i in range(6):
            num = random.randint(0 , 1)
            if(num not in sequences):
               sequences.append(num)
               b += 1;
            else:
                b += 1;

    print(sorted(sequences));
</code></pre>

<p>I understand you want to check in how many iterations you'll reach the 64 possible combinations. In that case this code does it:</p>

<pre><code>import math
import random

combs = set()
nb_iterations = 0
while len(combs)&lt;64:
    nb_iterations+=1
    a = (tuple(random.randint(0,1) for _ in range(6)))
    if a in combs:
        pass
    else:
        combs.add(a)

print("Done in {} iterations".format(nb_iterations))
</code></pre>

<p>I ran it a couple of times and it took around 300/400 iterations to get the full list.</p>

<p>Example of outputs:</p>

<pre><code>Done in 313 iterations
Done in 444 iterations
Done in 393 iterations
</code></pre>

python permutation