Re: possible pairings in a set

2009-04-13 Thread Alan G Isaac
I cannot access this thread right now so my answer my be rednundant, but anyway: http://docs.python.org/library/itertools.html#itertools.combinations >>> from itertools import combinations >>> print(list(combinations(range(4),2))) [(0, 1), (0, 2), (0, 3), (1, 2), (1, 3), (2, 3)] hth,

Re: possible pairings in a set

2009-04-13 Thread Przemyslaw Kaminski
Ross wrote: > I'm new to python and I'm trying to come up with a function that takes > a given number of players in a game and returns all possible unique > pairings. Here's the code I've come up with so far, but I'm not > getting the output I'd like to: > > def all_pairings(players): > cleanlist

Re: possible pairings in a set

2009-04-04 Thread Steven D'Aprano
On Sat, 04 Apr 2009 17:42:58 -0700, Ross wrote: > I'm new to python and I'm trying to come up with a function that takes a > given number of players in a game and returns all possible unique > pairings. Here's the code I've come up with so far, but I'm not getting > the output I'd like to: Others

Re: possible pairings in a set

2009-04-04 Thread Dave Angel
MRAB wrote: Dave Angel wrote: Ross wrote: I'm new to python and I'm trying to come up with a function that takes a given number of players in a game and returns all possible unique pairings. Here's the code I've come up with so far, but I'm not getting the output I'd like to: def all_pairi

Re: possible pairings in a set

2009-04-04 Thread MRAB
Dave Angel wrote: Ross wrote: I'm new to python and I'm trying to come up with a function that takes a given number of players in a game and returns all possible unique pairings. Here's the code I've come up with so far, but I'm not getting the output I'd like to: def all_pairings(players):

Re: possible pairings in a set

2009-04-04 Thread Dave Angel
Ross wrote: I'm new to python and I'm trying to come up with a function that takes a given number of players in a game and returns all possible unique pairings. Here's the code I've come up with so far, but I'm not getting the output I'd like to: def all_pairings(players): cleanlist =

RE: possible pairings in a set

2009-04-04 Thread John Posner
>> Also, if my code is considered ugly or redundant by this community, >> can you make suggestions to clean it up? Python is pretty mature: if you have a simple, generic problem, the chances are that someone else has already solved it, packaging the solution in a library (or "module"). For your

Re: possible pairings in a set

2009-04-04 Thread Benjamin Peterson
Ross gmail.com> writes: > Can you guys help me out? Do you have Python 2.6? If so, it's a solved problem. :) import itertools possible_pairings = list(itertools.combinations(players, 2)) -- http://mail.python.org/mailman/listinfo/python-list

possible pairings in a set

2009-04-04 Thread Ross
I'm new to python and I'm trying to come up with a function that takes a given number of players in a game and returns all possible unique pairings. Here's the code I've come up with so far, but I'm not getting the output I'd like to: def all_pairings(players): cleanlist = [] for i