toqito.perms.unique_perms

Unique permutations is used to calculate the unique permutations of a list/vector and their count.

Module Contents

class toqito.perms.unique_perms.UniqueElement[source]

Class for unique elements to keep track of occurrences.

value: int
occurrences: int
toqito.perms.unique_perms.unique_perms(elements)[source]

Determine the number of unique permutations of a list.

Examples

Consider the following vector

[

left[1, 1, 2, 2, 1, 2, 1, 3, 3, 3right].

]

The number of possible permutations possible with the above vector is (4200). This can be obtained using the |toqito⟩ package as follows.

```python exec=”1” source=”above” 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)))) ```

Parameters:

elements (list[int]) – List of integers.

Returns:

The number of possible permutations possible.

toqito.perms.unique_perms.perm_unique_helper(list_unique, result_list, elem_d)[source]

Provide helper function for unique_perms.

Parameters:
  • list_unique (list[UniqueElement]) – list[UniqueElement]

  • result_list (list[int]) – list[int]

  • elem_d (int) – int