Python Forum

Full Version: More Efficent Way of Generating Permutations/ w Rep
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,

My current method of generating permutations with repetition is to first generate all combinations with repetition, then find the permutations (w/out repetition) of each combination, and lastly to remove all copies.

Can anyone suggest a more efficient way of doing this?

Sorry I can't provide source code... I use Scheme/Lisp not Python (but I know this is a good site, so that's why I ask).
What about the solutions in 35 programming languages from rosetta code?

Edit: hmm, I'm not sure they are so good after all...
In Python built-in module itertools is permutations() function.