A puzzle for Pythonistas
jack at performancedrivers.com
Sat Feb 1 14:20:44 CET 2003
On Sat, Feb 01, 2003 at 12:34:29PM +0100, Anton Vredegoor wrote:
> On 31 Jan 2003 04:59:17 -0800, alan_salmoni at yahoo.com (Alan James
> Salmoni) wrote:
> >The problem is defined like this: I have a list of unique integers,
> >and the list is of arbitrary length, though 2 elements is the minimum.
> >Using each integer only once, what are the possible combinations of 2
> >or more elements that can be derived from this list. I know how to
> Since the list is of arbitrary length the number of combinations can
> become extremely large. If that is the case, indexed combinations are
> preferable instead of generating or computing the whole list of
> combinations, because of time or memory limitations.
the combination object at probstat.sourceforge.net I mentioned earlier
creates each combination when it is asked for. So you can have very
large data sets and the memory usage is linear.
It is also written in C so it is much faster than a pure-python equiv.
A few hundred people have used it, so it is at least relatively bug free :)
More information about the Python-list