A puzzle for Pythonistas

Jack Diederich jack at performancedrivers.com
Fri Jan 31 11:06:54 EST 2003


On Fri, Jan 31, 2003 at 04:59:17AM -0800, Alan James Salmoni wrote:
> Hi folks,
> 
> This is just a little puzzle to test your brains on - well, I should
> come clean really, so what I need to do is work out a way to get all
> the interactions from 2 or more variables for SalStat a small
> statistics package, but to be honest, I am rather stuck on this bit.
> 
> 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
> work out how many combinations there are: ((2**len(list))-1-len(list))
> which is quite simple.

probstat.sourceforge.net has fast permutation/combination classes.
None perfectly match what you are looking for but using them in combo
with the other replies will make the bits go faster.

Partial disclosure, I wrote the module.
It is textbook C algorithms with python wrappers.

-jackdied





More information about the Python-list mailing list