Combinatorics — Dudeney-Derived Algorithms
Catalan numbers, derangements, cycle decomposition, Josephus problem, grid paths, binomial/multinomial coefficients, and linear extensions. Pure Rust via nexcore-combinatorics.
12 toolscombinatorics
Catalan
Compute the nth Catalan number C(n).
n
Catalan Table
Get the first 20 Catalan numbers as a lookup table.
no params
Cycle Decomposition
Decompose a permutation into disjoint cycles.
permutation
Min Transpositions
Compute minimum transpositions to sort a permutation.
permutation
Derangement
Compute D(n), the number of derangements of n elements.
n
Derangement Probability
Probability D(n)/n! that a random permutation is a derangement (converges to 1/e).
n
Grid Paths
Count monotone lattice paths from (0,0) to (m,n).
mn
Binomial
Compute binomial coefficient C(n,k).
nk
Multinomial
Compute multinomial coefficient from group lengths.
lengths
Josephus
Compute Josephus survivor position (0-indexed) for n people, every kth eliminated.
nk
Elimination Order
Full Josephus elimination order.
nk
Linear Extensions
Count linear extensions for independent chains.
chain_lengths