title: All possible assignment vectors of 2n users
body: <p>I would like to write a function to calculate all possible assignment vectors of 2n users, where n users are assigned to group 0 (control), and n users are assigned to group 1 (treatment).</p>
  
  <p>I've tried a recursive approach as you can see below, but I know it can not work like this (I should have C(2n,n) vectors I think, right?)</p>
  
  <p>Any ideas?</p>
  
  <p>Thanks.</p>
  
  <pre><code>def algo(n):
     T = list();
     if n&gt;=2 :
        for j in range(len(algo(n-1))/2):
           T.append([0,1]+algo(n-1)[j]);
        for j in range(len(algo(n-1))/2):
           T.append([1,0]+algo(n-1)[j]);
        for j in (len(algo(n-1)/2):(len(algo(n-1)*(3/4)):
           T.append([0,0]+algo(n-1)[j]);    
        for j in range(len(algo(n-1))):
           T.append([1,1]+algo(n-1)[j]);
     if n==1 :
        T=[[0,1],[1,0],[0,0],[1,1]];
     return T
  </code></pre>