Permutation
Generation of all the permutations of an iterable.
permutations(iterable, r=None)
Generate all the r length permutations of an iterable (n factorial possibilities).
Examples:
>>> permutations('ABCD', 2)
'AB', 'AC', 'AD', 'BA', 'BC', 'BD', 'CA', 'CB', 'CD', 'DA', 'DB', 'DC' >>> permutations(range(3)) '012', '021', '102', '120', '201', '210'
Code taken from https://docs.python.org/3/library/itertools.html.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
iterable |
Union[list, ndarray, tuple]
|
Iterable to generate the permutations from |
required |
r |
Union[int, None]
|
Length of the permutations, by default None If None, then r defaults to the length of the iterable |
None
|
Returns:
Type | Description |
---|---|
generator
|
Generator of permutations |