unique_perms
¶
Unique permutations is used to calculate the unique permutations of a list/vector and their count.
UniqueElement
dataclass
¶
Class for unique elements to keep track of occurrences.
unique_perms
¶
Determine the number of unique permutations of a list.
Parameters:
-
elements(list[int]) –List of integers.
Returns:
-
None–The number of possible permutations possible.
Examples:
Consider the following vector
\[
\left[1, 1, 2, 2, 1, 2, 1, 3, 3, 3\right].
\]
The number of possible permutations possible with the above vector is \(4200\). This can be
obtained using the |toqito⟩ package as follows.
from toqito.perms import unique_perms
vec_nums = [1, 1, 2, 2, 1, 2, 1, 3, 3, 3]
print(len(list(unique_perms(vec_nums))))
Source code in toqito/perms/unique_perms.py
perm_unique_helper
¶
perm_unique_helper(
list_unique: list[UniqueElement],
result_list: list[int],
elem_d: int,
) -> Generator[tuple[int, ...], None, None]
Provide helper function for unique_perms.
Parameters:
-
list_unique(list[UniqueElement]) –list[UniqueElement]
-
result_list(list[int]) –list[int]
-
elem_d(int) –int