title: Custom permutation, Equal distribution of pairs
body: <p>I've been playing with a strange problem for a few weeks and can't seem to get the results I want. </p>
  
  <p>I'd like to take a permutation of a list of objects to get unique pairs. Then order them in a particular way to maximize equal distribution of the objects at any point in the list. This also means that if an object is at the beginning of a pair if should also be at the end of a pair soon after. No pairs can repeat.  To clarify, here is an example.</p>
  
  <p>list (A,B,C,D) might result in the following:</p>
  
  <pre><code>(A,B)
  (C,D)
  (B,A)
  (D,C)
  (A,C)
  (B,D)
  (C,A)
  (D,B)
  (A,D)
  (B,C)
  (D,A)
  (C,B)
  </code></pre>
  
  <p>Notice, every letter is used every 2 pairs, and the letters switch positions frequently.</p>
  
  <p>To get the permutation I used the python script:</p>
  
  <pre><code>perm = list(itertools.permutations(list,2))
  </code></pre>
  
  <p>which gave me 12 pairs of the letters.</p>
  
  <p>I then manually ordered the pairs so the each letter is chosen as often as possible and switches position as often as possible. At any point in the list the letters will be distributed very equally. When I go through the process of figuring out this problem I know where in the list I will stop but I don't know how much that effects the order the pairs are placed in.</p>
  
  <p>With 4 letters it can be done easier because (4 letters / 2 pairs) = 2. 
  I also would like this to work with odd permutation pairs as well. </p>
  
  <p>For example:</p>
  
  <p>A,B.C</p>
  
  <p>A,B,C,D,E</p>
  
  <p>etc..</p>
  
  <p>I have tried this a number of ways and tried to recognize patterns and while there are plenty, there is just many ways to do this problem especially. There also may not be a perfect answer.</p>
  
  <p>I have also tried taking a normal permutation of the letters P(4,4) or in the case of 5 letters P(5,5), and I've tried picking certain permutations, combining them, and then chopping them up into pairs. This seems like another route but I can't seem to be able to figure out which pairs to pick unless I manually work through it.</p>
  
  <p>Any help is appreciated! Maybe try to point me in the right direction :)</p>
  
  <p>I ultimately will try to implement this into python but I don't necessarily need help writing the code. it's more a question of what the process might be.  </p>