Recursive function to develop permutations

Jack Diederich jack at
Tue Oct 19 18:52:52 CEST 2004

On Tue, Oct 19, 2004 at 12:34:57AM +0000, Steve Goldman wrote:
> Hi,
> I am trying to come up with a way to develop all n-length permutations of a
> given list of values.  The short function below seems to work, but I can't
> help thinking there's a better way.  Not being a computer scientist, I find
> recursive functions to be frightening and unnatural.  I'd appreciate if
> anyone can tell me the pythonic idiom to accomplish this.
> ###START CODE###

Combinatorics (permutations, combinations, etc) get golfed (shortest/fastest)
on a couple times a year.  Check for some solutions.
If you want fast, try which does some combinatorics in C with
a python wrapper.  disclosure: I wrote it.


More information about the Python-list mailing list