Python Forum
looking for a permutation function
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
looking for a permutation function
#1
i am looking for a permutation function (hoping i don't need to write one) that can take 3, 4, or 5 characters i give (no duplicats) and produce all possible combinations in every order (abcdef',fedcba','bdfeac',...) meeting these requirements:

1. no duplication of any letter.

2. every possible length from 1 to N. N is the number of different characters given.

3. every possible order

a generator is fine and probably preferred. i don't see anything in itertools that does this.
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply
#2
What's wrong with itertools.permutations?
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#3
i guess putting that in a loop and joining the tuples into strings can do every possibility.
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply


Forum Jump:

User Panel Messages

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