sharing/swapping items between lists

Ross ross.jett at gmail.com
Fri Apr 10 23:50:26 EDT 2009


I'm trying to design an iterator that produces two lists. The first
list will be a list of unique pairings and the second will be a list
of items that weren't used in the first list. After each round, the
items that weren't used in the round before will get put back in and
the second list will be populated with unique items. To clarify,
here's an example of what my output would be if I had 8 items:

First Iteration

LIST 1                    LEFTOVERS LIST

[(1,2),(3,4),(5,6)]       [7,8]

Second Iteration

[(1,3), (2,7),(4,8)]     [5,6]

Third Iteration

[(1,5), (2,6), (7,8)]    [3,4]

etc

Additionally, I want the items in the "leftovers" list to be used the
same amount.

Can you guys suggest an approach to this problem...I'm trying to teach
myself python so an outline of how to approach this would probably be
more helpful to me than an explicit solution. I'll cry mercy if I
can't figure it out after your hints.



More information about the Python-list mailing list