Inclusion–exclusion, derangements and the pigeonhole
COMB · Chapter 312 min readAsked at Jane Street, Optiver, SIG, IMC
Assumes Counting: the four cases, and how to tell them apart.
After this lesson you should be able to
- Apply inclusion–exclusion to "at least one" problems.
- Derive the derangement count and know its limit.
- Use a pigeonhole or parity argument to prove something is impossible.
Two techniques cover most of the counting problems that look hard. Inclusion–exclusion handles overlapping conditions, and its standard cue is the phrase "at least one". Pigeonhole and parity handle the questions that ask you to prove something *cannot* happen, which is a different kind of answer and needs a different reflex.
Equation 3.1
Inclusion–exclusion
Add the singles, subtract the pairs, add the triples, alternating. Each element ends up counted exactly once.
- The set of outcomes satisfying the -th condition.
Proposition 3.2
Take the complement first
When a problem says "at least one", the complement — "none" — is almost always the easier count. For independent conditions, , and you have avoided inclusion–exclusion entirely. Reach for the full alternating sum only when the conditions genuinely interact.
Holds when
- The birthday problem, the coupon collector and "at least one six in four rolls" all yield to the complement in one line.
- Inclusion–exclusion earns its keep when the events are structurally linked, as in derangements.
- Both A and B — 10 of 100
- A only — 30 of 100
- B only — 20 of 100
- Neither — 40 of 100
Derivation 3.4
Derangements — the hat-check problem
How many permutations of items leave nothing in its own place?
Pin one item and permute the rest.
Inclusion–exclusion over which items are fixed.
Subtract from the total and simplify.
Why the answer is . The probability that a random permutation is a derangement tends to , and it does so almost immediately: at it is already , and at it matches to four decimals. The reason is that each item fails to be fixed with probability roughly , and . The near-independence of the events is what makes a Poisson-style limit appear, and it is why the number of fixed points of a random permutation is approximately Poisson with mean one.
Example 3.5
Five traders hang up five identical-looking coats and each takes one at random. What is the probability nobody gets their own?
Show the worked solutionHide the worked solution
Worked solution
- Formula
- Substitute
- Solve
- Answer
Sanity check. Within of at only five items, which is the point of the intuition above.
The rest of this lesson is in Premium
You have read the opening. 14 more sections follow, including 5 worked examples and 3 quick checks.
Nothing is charged for 7 days, and you can cancel before then. Or read Arithmetic that survives a clock in full, free.