Combinatorics & Counting

Difficulty
Importance

The problem

‘How many possibilities are there?’ decides whether an approach is feasible: how many test cases cover the input space, how many states a system can reach, how big a search space an algorithm faces. Counting turns these from guesses into calculations.

Why now

Sets tell us what the space of possibilities is, but not its size when the space is built combinatorially (choices multiply, orderings explode). Enumerating by hand fails immediately — 10 boolean feature flags already give 1024 configurations.

Mental model

All of counting is two moves: multiply independent choices, add mutually exclusive cases — then correct for overcounting (divide out orderings, subtract overlaps). Permutations, combinations, and the inclusion–exclusion principle are these moves packaged.

Requires

Helps

Unlocks

Related

Used in

Projects

  • Compute the number of distinct configurations of a real config file in one of your projects; decide whether exhaustive testing is feasible
  • Simulate the birthday paradox and compare the empirical collision rate to the calculated one

Examples

  • 4 environments × 3 regions × 2 tiers = 24 deployment targets (product rule)
  • Number of ways to pick 3 reviewers from a team of 10: C(10,3) = 120 — order doesn't matter, so divide out the 3! orderings

Resources

Mastery checklist