count_distinct_permutations

def count_distinct_permutations(sequence)

Counts the number of distinct permutations of a sequence where items may be indistinguishable.

Arguments:

  • sequence iterable - The sequence for which to count the distinct permutations.

Returns:

  • int - The number of distinct permutations.

Example:

count_distinct_permutations(‘aab’) 3 count_distinct_permutations([1, 2, 2]) 3