Python Forum
More Efficent Way of Generating Permutations/ w Rep
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
More Efficent Way of Generating Permutations/ w Rep
#1
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).
Reply
#2
What about the solutions in 35 programming languages from rosetta code?

Edit: hmm, I'm not sure they are so good after all...
Reply
#3
In Python built-in module itertools is permutations() function.
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy

Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Creating permutations of N size with no same elements next to one another (recursion) melmoman 1 1,503 Dec-18-2021, 09:39 PM
Last Post: Larz60+
  What happens to a <itertools.permutations object at 0x7fe3cc66af68> after it is read? Pedroski55 3 2,353 Nov-29-2020, 08:35 AM
Last Post: DeaD_EyE
  Permutations mikke3141 2 19,086 Dec-23-2019, 06:09 PM
Last Post: mikke3141
  permutations calculation with a while instruction kwak86 2 2,238 Sep-10-2018, 02:09 PM
Last Post: kwak86
  How to find the number of permutations of a list of lists? JoeB 5 5,299 Nov-18-2017, 06:31 PM
Last Post: heiner55

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020