Combinatorics Fundamentals

Core counting principles and combinatorial formulas.

  • JSON5,665 B
  • YAML4,169 B · −26%
  • TOON3,392 B · −40%

The counting principles used to enumerate possibilities: the sum and product rules, permutations and combinations (with and without repetition), the pigeonhole principle and the binomial theorem, plus inclusion-exclusion, derangements, stars and bars, Catalan and Stirling numbers. Each entry has the principle, a one-line description and the formula.

Use it when

  • You need the right counting formula for a probability or algorithm-analysis problem.
  • You are checking whether a count is ordered or unordered, with or without repetition.

Watch out for

  • Formulas assume distinguishable items unless stated; identical items need the multinomial or repetition variants.
  • Notation varies: C(n, k), nCk and the binomial coefficient all mean the same count.

The data

PrincipleDescriptionFormula
Product RuleIf task A has m ways and task B has n ways, both can be done in m * n ways.m * n
Sum RuleIf tasks are mutually exclusive with m and n ways, total is m + n.m + n
PermutationsOrdered arrangements of r elements from n items.P(n,r) = n! / (n - r)!
CombinationsUnordered selections of r elements from n items.C(n,r) = n! / (r!(n-r)!)
Permutations with RepetitionArrangements when some elements are identical.n! / (n1! * n2! * ... * nk!)
Pigeonhole PrincipleIf n items are placed into m containers and n > m, some container has >= 2 items.ceil(n/m)
Binomial TheoremExpansion of (a + b)^n.(a+b)^n = Sum C(n,k) * a^(n-k) * b^k
Inclusion-Exclusion PrincipleCounts the union of sets by adding single sets, subtracting pairwise overlaps, adding triple overlaps, and so on.|A ∪ B| = |A| + |B| − |A ∩ B|
Combinations with RepetitionChoose k items from n types where an item can be chosen more than once and order does not matter.C(n + k - 1, k)
Stars and BarsCounts ways to distribute n identical items into k distinct bins.C(n + k - 1, k - 1)
Multinomial CoefficientCounts arrangements of n items with k1, k2, ... km identical items of each kind.n! / (k1! k2! ... km!)
Circular PermutationsArrangements of n distinct objects around a circle, where rotations count as the same arrangement.(n - 1)!
DerangementsPermutations in which no element appears in its original position.!n = n! (1 - 1/1! + 1/2! - ... + (-1)^n / n!)
Pascal's RuleEach binomial coefficient is the sum of the two above it in Pascal's triangle.C(n, k) = C(n - 1, k - 1) + C(n - 1, k)
Catalan NumbersCount balanced parentheses, binary trees with n nodes, and monotonic lattice paths that stay on one side of the diagonal.C_n = C(2n, n) / (n + 1)
Stirling Numbers of the Second KindNumber of ways to partition n labeled items into k non-empty unlabeled subsets.S(n, k) = k S(n - 1, k) + S(n - 1, k - 1)

Fields

The shape of this dataset, read from the data itself: every column, its type and a real value. Agents can use this to plan a query without fetching the whole document.

SectionFieldTypeExample
dataprinciplestringProduct Rule
datadescriptionstringIf task A has m ways and task B has n ways, bot…
dataformulastringm * n

Fetch the same bytes

The static files contain the same reference rows as the API, with no API rate limit. Live metadata, such as view counts, may differ. Use the API for content negotiation; use the static files for a cacheable snapshot.

curl "https://yjtoon.yunusemrevurgun.com/api/dataset/combinatorics-fundamentals?format=toon"
const res = await fetch(
  "https://yjtoon.yunusemrevurgun.com/static-data/dataset/combinatorics-fundamentals.toon"
);
const toon = await res.text();

Rate limit: 120 requests per minute per IP, no key and no signup. API reference →

Topics

  • math
  • combinatorics
  • counting
  • permutations
  • combinations

Search the library

Search by a topic, title, or keyword.

Start with a collection

Browse all 205 datasets