perms.unique_perms

Calculate unique permutations.

Module Contents

Classes

UniqueElement

Class for unique elements to keep track of occurrences.

Functions

unique_perms(elements)

Determine the number of unique permutations of a list.

perm_unique_helper(list_unique, result_list, elem_d)

Provide helper function for unique_perms.

class perms.unique_perms.UniqueElement

Class for unique elements to keep track of occurrences.

value: int
occurrences: int
perms.unique_perms.unique_perms(elements)

Determine the number of unique permutations of a list.

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]
>>> len(list(unique_perms(vec_nums)))
4200
Parameters:

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

Returns:

The number of possible permutations possible.

perms.unique_perms.perm_unique_helper(list_unique, result_list, elem_d)

Provide helper function for unique_perms.

Parameters:
  • list_unique (list[UniqueElement])

  • result_list (list[int])

  • elem_d (int)

Returns: