Examples#
This gallery walks through every public feature of mathematicskit.combinatorics:
permutation/combination counting and generation, Pascal’s triangle,
integer partitions, the inclusion-exclusion principle, and Stirling/
Catalan/Bell numbers.
See also the narrative tutorial:
Each script in this gallery is self-contained and can be run directly with
python examples/combinatorics/<section>/<script>.py.
Sections#
counting – permutation/combination counting and sequence generation, and multinomial coefficients.
pascals_triangle – the binomial-coefficient recurrence.
partitions – the partition function, enumeration, and Young diagrams.
inclusion_exclusion – the inclusion-exclusion principle and derangements.
special_numbers – Stirling numbers, Catalan numbers, and Bell numbers.
Counting#
Permutation/combination counting and generation, and multinomial coefficients.
Combinatorial designs#
Latin squares and orthogonal pairs.
Extremal combinatorics#
Ramsey’s theorem and the Erdős-Szekeres theorem: order that must appear in any large enough structure.
Inclusion-exclusion#
The inclusion-exclusion principle and derangements.
The hat-check problem: derangements via inclusion-exclusion
Matchings#
Hall’s marriage theorem and bipartite matchings.
Necklaces#
Pólya enumeration: counting colorings up to symmetry.
Pólya’s enumeration theorem: necklaces and bracelets
Integer partitions#
The partition function, enumeration, and Young diagrams.
Integer partitions, the partition function, and Young diagrams
Pascal’s triangle#
The binomial-coefficient recurrence, built by hand.
Pascal’s triangle vs. scipy-computed binomial coefficients
Integer sequences#
Fibonacci numbers, Bernoulli numbers and sums of powers, and Gray codes.
Special numbers#
Stirling numbers, Bell numbers, and Catalan numbers.
Stirling’s numbers: cycles, set partitions, and Bell numbers
Catalan numbers: Euler’s polygon triangulations and Catalan’s brackets
Labeled trees#
Cayley’s formula and Prüfer codes.