combinatorics: Functions for combinatorics

Functions for combinatorics (combinations with repetitions, derangements, etc.)

Functions

combinations_with_repetition(seq, size)

Yield all combinations of the elements of seq :rtype: Iterator[tuple[TypeVar(T), ...]]

derangements(seq)

Permutations of seq where each element is not in its original position

distance_from_sorted(seq[, offset])

Distance between seq and a sorted seq.

random_distance(length[, numseqs])

Calculate the distance between a sorted seq.

random_range(length)

Return an array of ints from 0 to length-1, in random order

unsort(seq, entropy[, margin, tolerance, ...])

Generate a permutation of xs unsorted according to the given entropy.

unsort2(xs[, entropy, margin, error, numiter])

unsortedness(seq)

The entropy of the ordering in this seq.