How can I create unique non-repeating pair combinations from a list
<p>I am new to computer programming.  </p>

<p>I want to create successive 2-person teams from an even numbered list of players (32 max) but with no repeats until all possible teams have been formed.  </p>

<p>For example for 6 players (a thru f) I can generate with itertools.combinations 15 distinct teams. Then I can manually, on paper, in a matrix create 5 sets of 3 unique teams(i.e. [['a','b'],['c','d'], ['e','f']], and similarly ac,bf,de; ae,bc,df; af,bd,ce and ad,be,cf). But I've been unable to write a program (many varied attempts) in python 3.5 to do this. After 5 or fewer iterations I get repeats and some possible teams are not created at all.</p>

<p>I did a search but cannot quite discern which solution applies in my specific case.</p>

<p>Here's a typical scenario of what I'm trying to accomplish:
Roster of about 26 players
Week 1: 18 of 26 show up. I form 9 teams
Week 2: 22 of 26 show up. I form 11 teams but no repeats from Week 1
Week 3: 10 of 26 show up. I form 5 teams but no repeats from Week 1 or Week 2, etc.</p>

<p>The following works, albeit without the past__teams filter applied (yet), with up to 12 players (takes 25 secs) but beyond 12 is unbearably long, and I expect about 24 players.
The program selects the first valid set of teams then ends.  With the additional past__teams filter applied - the whole point of the program - it will have to run even longer.
Is there an alternate approach to this problem or a way to speed it up considerably?</p>

<pre><code>from itertools import combinations, chain
import pickle, random
'''the'past__teams.py' file was previously created as follows:
output = open('past__teams.pkl', 'wb')
pickle.dump(past__teams, output)
output.close()'''
players = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']
random.shuffle(players)
#load the past__teams file into the program
pkl_file = open('past__teams.pkl', 'rb')
past__teams = pickle.load(pkl_file)
pkl_file.close()

all_pair_combinations= []
tonights_teams = []
for c in combinations(players, 2):
    c = list(c)
    all_pair_combinations.append(c)

def dupe_test(L):
    if len(L) != len(set(L)):
        return True
    return False
y = 0
for t in combinations(all_pair_combinations, int(len(players)/2)):
    t = list(t)
    tt =list(chain(*t))
    y = y +1
    if dupe_test(tt) == False:
        tonights_teams =t
        break
print ()
print ("Tonights_teams: ",y,tonights_teams)
</code></pre>

python itertools