Pigeonhole Principle
If you put more pigeons into fewer holes, at least two pigeons must share a hole. This elementary fact powers some of the most surprising results in mathematics. With only 23 people in a room, there’s a 50% chance two share a birthday. Most people guess 183. The principle is simple. The intuition is broken.
P(collision, n, d) = 1 − ∏i=0n-1 (d − i)/d ≈ 1 − e−n(n−1)/(2d)
The pigeonhole principle
If n items are placed into m containers and n > m, then at least one container must hold more than one item. This is the pigeonhole principle (Schubfachprinzip), stated by Dirichlet in 1834. It is trivially true and profoundly useful — it powers results across combinatorics, number theory, computer science, and cryptography.
The birthday paradox
With 365 possible birthdays (pigeonholes) and n people (pigeons), the probability of at least one shared birthday is P = 1 − 365!/((365−n)!·365n). This exceeds 50% at just n = 23, and 99% at n = 57. The paradox is not mathematical but psychological — humans compare n to 365 instead of to the number of pairs, which is n(n−1)/2.
The sock drawer
A drawer has socks of k colors. How many must you draw (blindfolded) to guarantee a matching pair? By the pigeonhole principle: k + 1. The first k draws could each produce a different color. The (k+1)-th must match one of them. This is the principle in its purest form.
Hash collisions and the birthday attack
A hash function maps arbitrary inputs into a fixed space of d values. By the birthday paradox, a collision becomes likely after roughly √(d) insertions, not d. For a 128-bit hash (d = 2128), collisions appear after about 264 attempts. This is the birthday attack, and it halves the effective security of any hash. It is the reason cryptographic hashes need to be twice as wide as the desired security level.
Why intuition fails
The human mind estimates probabilities linearly. We intuit that 23 people from 365 days means roughly 23/365 ≈ 6% chance of a match. But collisions grow quadratically with the number of items (because the number of pairs grows as n²), and our linear intuition systematically underestimates this.