Recursive function to develop permutations

Thorsten Kampe thorsten at thorstenkampe.de
Fri Oct 22 06:50:56 EDT 2004


* Steve Goldman (2004-10-19 02:34 +0200)
> I am trying to come up with a way to develop all n-length permutations of a
> given list of values.

I'm sorry but there are no "n-length permutations" in
mathematics/combinatorics. There are variations and combinations -
each of them with and without repetition. The difference is that with
combinations order of the elements is irrelevant and with variations
order is relevant.

Permutations always have the full length of the original list.
Permutations are divided in permutations with and without repetition
(like combinations and variations).

For an (unoptimized) version of permutations see:
http://www.python.org/doc/current/ref/indentation.html


Thorsten

PS If you are interested I can post the code for all six
possibilities. The code computes optionally the size of the result
list (because this grows big very soon) so you don't run out of memory
or time



More information about the Python-list mailing list