Skip to content

Instantly share code, notes, and snippets.

@Wind010
Created August 5, 2024 23:13
Show Gist options
  • Save Wind010/02eb7e9f593690b2bc7d7ad65742c0cd to your computer and use it in GitHub Desktop.
Save Wind010/02eb7e9f593690b2bc7d7ad65742c0cd to your computer and use it in GitHub Desktop.
Create permutations of a list of objects up to n selected combined elements.
import itertools
n = 3
names = [
"Jordan", "Haig", "Emily", "Johns", "Elisa", "Maldonado", "Brandi", "Simmons", "Gerard", "Sekawa", "Shelly", "Buckle", "Alice", "Apple", "Maxis", "Stewart", "Olivia", "Johnson", "Ava", "Brown", "Sophia", "Taylor", "Amelia", "Davis", "Evelyn", "Rodriguez", "Emma", "Smith", "Charlotte", "Jones", "Mia", "Miller", "Harper", "Garcia", "Abigail", "Martinez"
]
permutations = [''.join(p) for p in itertools.product(names, repeat=n)]
[print(perm) for perm in permutations]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment