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,
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
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
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
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):
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 =
>> 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
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
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