Re: sharing/swapping items between lists

2009-04-15 Thread MRAB
samwyse wrote: On Apr 15, 8:13 am, Aaron Brady wrote: On Apr 15, 6:57 am, samwyse wrote: Here's my idea: generate all possible pairs: import itertools players = [chr(c) for c in xrange(ord('a'),ord('z')+1)] all_pairs = list(itertools.combinations(players,2)) partition the list: def choos

Re: sharing/swapping items between lists

2009-04-15 Thread Aaron Brady
On Apr 15, 11:29 am, samwyse wrote: > On Apr 15, 8:56 am, Aaron Brady wrote: > > > > > The randomizing solution isn't quite suitable for 16 teams.  With 5 > > teams/1 court, and 5 teams/2 courts, 6 teams/2 courts, the solution > > comes within seconds.  For 7 teams/3 courts, the solution takes a

Re: sharing/swapping items between lists

2009-04-15 Thread samwyse
On Apr 15, 8:56 am, Aaron Brady wrote: > > The randomizing solution isn't quite suitable for 16 teams.  With 5 > teams/1 court, and 5 teams/2 courts, 6 teams/2 courts, the solution > comes within seconds.  For 7 teams/3 courts, the solution takes a few > minutes. 7 teams/3 courts is the same as 8

Re: sharing/swapping items between lists

2009-04-15 Thread samwyse
On Apr 15, 8:13 am, Aaron Brady wrote: > On Apr 15, 6:57 am, samwyse wrote: > > > Here's my idea: generate all possible pairs: > > > >>> import itertools > > >>> players = [chr(c) for c in xrange(ord('a'),ord('z')+1)] > > >>> all_pairs = list(itertools.combinations(players,2)) > > > partition th

Re: sharing/swapping items between lists

2009-04-15 Thread Aaron Brady
On Apr 14, 9:45 pm, Ross wrote: > On Apr 14, 7:18 pm, Aaron Brady wrote: > > > > > On Apr 14, 7:01 pm, Aaron Brady wrote: > > > > On Apr 14, 12:37 pm, Ross wrote: > > > > > On Apr 14, 10:34 am, Ross wrote: > > > > > > On Apr 14, 5:57 am, a...@pythoncraft.com (Aahz) wrote: > > > > > > > In arti

Re: sharing/swapping items between lists

2009-04-15 Thread Aaron Brady
On Apr 15, 6:57 am, samwyse wrote: > On Apr 14, 7:01 pm, Aaron Brady wrote: > > > Here is an idea.  Create a list of all possible pairs, using > > itertools.combinations.  You'll notice everyone gets equal play time > > and equal time against each other on a pair-by-pair basis.  Then, call > > ra

Re: sharing/swapping items between lists

2009-04-15 Thread samwyse
On Apr 14, 7:01 pm, Aaron Brady wrote: > Here is an idea.  Create a list of all possible pairs, using > itertools.combinations.  You'll notice everyone gets equal play time > and equal time against each other on a pair-by-pair basis.  Then, call > random.shuffle until one player isn't playing on t

Re: sharing/swapping items between lists

2009-04-15 Thread Aaron Brady
On Apr 14, 9:45 pm, Ross wrote: > On Apr 14, 7:18 pm, Aaron Brady wrote: > > > > > On Apr 14, 7:01 pm, Aaron Brady wrote: > > > > On Apr 14, 12:37 pm, Ross wrote: > > > > > On Apr 14, 10:34 am, Ross wrote: > > > > > > On Apr 14, 5:57 am, a...@pythoncraft.com (Aahz) wrote: > > > > > > > In arti

Re: sharing/swapping items between lists

2009-04-14 Thread Ross
On Apr 14, 7:18 pm, Aaron Brady wrote: > On Apr 14, 7:01 pm, Aaron Brady wrote: > > > > > On Apr 14, 12:37 pm, Ross wrote: > > > > On Apr 14, 10:34 am, Ross wrote: > > > > > On Apr 14, 5:57 am, a...@pythoncraft.com (Aahz) wrote: > > > > > > In article > > > > > , > > > > > > Ross   wrote: > >

Re: sharing/swapping items between lists

2009-04-14 Thread Aaron Brady
On Apr 14, 7:01 pm, Aaron Brady wrote: > On Apr 14, 12:37 pm, Ross wrote: > > > > > On Apr 14, 10:34 am, Ross wrote: > > > > On Apr 14, 5:57 am, a...@pythoncraft.com (Aahz) wrote: > > > > > In article > > > > , > > > > > Ross   wrote: > > > > >On Apr 13, 9:08=A0am, a...@pythoncraft.com (Aahz) w

Re: sharing/swapping items between lists

2009-04-14 Thread Aaron Brady
On Apr 14, 12:37 pm, Ross wrote: > On Apr 14, 10:34 am, Ross wrote: > > > > > On Apr 14, 5:57 am, a...@pythoncraft.com (Aahz) wrote: > > > > In article > > > , > > > > Ross   wrote: > > > >On Apr 13, 9:08=A0am, a...@pythoncraft.com (Aahz) wrote: > > > >> In article > > > >> > > >com>, > > > >>

Re: sharing/swapping items between lists

2009-04-14 Thread Ross
On Apr 14, 10:34 am, Ross wrote: > On Apr 14, 5:57 am, a...@pythoncraft.com (Aahz) wrote: > > > > > In article > > , > > > Ross   wrote: > > >On Apr 13, 9:08=A0am, a...@pythoncraft.com (Aahz) wrote: > > >> In article > > >> > >com>, > > >> Ross =A0 wrote: > > > >>>I'm sorry...my example was pro

Re: sharing/swapping items between lists

2009-04-14 Thread Ross
On Apr 14, 5:57 am, a...@pythoncraft.com (Aahz) wrote: > In article , > > > > Ross   wrote: > >On Apr 13, 9:08=A0am, a...@pythoncraft.com (Aahz) wrote: > >> In article >com>, > >> Ross =A0 wrote: > > >>>I'm sorry...my example was probably a bad one. A better example of > >>>output I would like wou

Re: sharing/swapping items between lists

2009-04-14 Thread Aahz
In article , Ross wrote: >On Apr 13, 9:08=A0am, a...@pythoncraft.com (Aahz) wrote: >> In article com>, >> Ross =A0 wrote: >>> >>>I'm sorry...my example was probably a bad one. A better example of >>>output I would like would be something like [[1,2],[3,4],[5,6]] and >>>then for the leftovers list

Re: sharing/swapping items between lists

2009-04-14 Thread Aaron Brady
On Apr 13, 11:52 pm, Aaron Brady wrote: > On Apr 13, 10:04 am, Ross wrote: > > > > > On Apr 11, 1:10 pm, a...@pythoncraft.com (Aahz) wrote: > > > > In article > > > <4fd78ac3-ba83-456b-b768-3a0043548...@f19g2000vbf.googlegroups.com>, > > > > Ross   wrote: > > > > >I'm trying to design an iterato

Re: sharing/swapping items between lists

2009-04-13 Thread Aaron Brady
On Apr 13, 10:04 am, Ross wrote: > On Apr 11, 1:10 pm, a...@pythoncraft.com (Aahz) wrote: > > > > > In article > > <4fd78ac3-ba83-456b-b768-3a0043548...@f19g2000vbf.googlegroups.com>, > > > Ross   wrote: > > > >I'm trying to design an iterator that produces two lists. The first > > >list will be

Re: sharing/swapping items between lists

2009-04-13 Thread Ross
On Apr 13, 9:08 am, a...@pythoncraft.com (Aahz) wrote: > In article , > > Ross   wrote: > > >I'm sorry...my example was probably a bad one. A better example of > >output I would like would be something like [[1,2],[3,4],[5,6]] and > >then for the leftovers list [7,8,9,10 etc]. What I'm trying to do

Re: sharing/swapping items between lists

2009-04-13 Thread Aahz
In article , Ross wrote: > >I'm sorry...my example was probably a bad one. A better example of >output I would like would be something like [[1,2],[3,4],[5,6]] and >then for the leftovers list [7,8,9,10 etc]. What I'm trying to do is >produce some sort of round robin algorithm for tennis that is

Re: sharing/swapping items between lists

2009-04-13 Thread Ross
On Apr 11, 1:10 pm, a...@pythoncraft.com (Aahz) wrote: > In article > <4fd78ac3-ba83-456b-b768-3a0043548...@f19g2000vbf.googlegroups.com>, > > Ross   wrote: > > >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 l

Re: sharing/swapping items between lists

2009-04-11 Thread Aahz
In article <4fd78ac3-ba83-456b-b768-3a0043548...@f19g2000vbf.googlegroups.com>, Ross wrote: > >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,

Re: sharing/swapping items between lists

2009-04-10 Thread Paul Rubin
Ross writes: > 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. Look at the "set" datatype. Th