Crate permutator[][src]

Generic permutator that can get a combination at any specific point.

Functions

divide_factorial

Calculate factorial for two factorial division. It'll return 1 if numerator is smaller or equals to denominator. Otherwise, it'll short circuit the calculation by calculate only the undivided remainder.

factorial

Calculate factorial from given value.

get_cartesian_for

Get a cartesian product at specific location. If objects is [1, 2, 3] and degree is 2 then all possible result is [1, 1], [1, 2], [1, 3], [2, 1], [2, 2], [2, 3], [3, 1], [3, 2], [3, 3]

get_cartesian_size

Calculate all possible cartesian combination size. It is always equals to size.pow(degree).

get_permutation_for

Get permutation at specific location. If objects is [1, 2, 3, 4] and degree is 2 then all possible permutation will be [1, 2], [1, 3], [1, 4], [2, 1], [2, 3], [2, 4], [3, 1], [3, 2], [3, 4], [4, 1], [4, 2], [4, 3].

get_permutation_size

Calculate all possible number of permutation. It's equals to size!/(size - 1).

multiply_factorial

Calculate two factorial multiply on each other. It'll try to reduce calculation time by calculate the common value only once.