Pigeonhole Principle and Inclusion-Exclusion
364 words
2 min read
Visual companion
Python
Type and operator map
Python Week 1: the first filter for runtime behavior
View
Revision summary
What this note is really saying
Short form
# Pigeonhole Principle and Inclusion-Exclusion ## 2.1 Pigeonhole Principle **Simple form:** If $n$ items are placed into $m$ boxes and $n > m$, then at least one box contains at least 2 items. **Generalized form:** If $n$ items are placed into $m$ boxes, then at least one box contains at least $\lceil n/m \rceil$ it...

Pigeonhole Principle and Inclusion-Exclusion
2.1 Pigeonhole Principle
Simple form: If n items are placed into m boxes and n>m, then at least one box contains at least 2 items.
Generalized form: If n items are placed into m boxes, then at least one box contains at least ⌈n/m⌉ items.
Applications
Example 1: Among any 13 people, at least 2 share the same birth month. (13>12)
Example 2: In any set of 5 points in a 2×2 square, some pair are within 2 distance. (Divide into 4 unit squares; by pigeonhole, 2 points in same square, max distance = 2.)
Example 3: Any subset of size 6 from {1,2,…,9} contains two numbers summing to 10. (Pairs: {1,9},{2,8},{3,7},{4,6},{5}; 5 pigeonholes, 6 pigeons.)
2.2 Inclusion-Exclusion Principle
For two sets: ∣A∪B∣=∣A∣+∣B∣−∣A∩B∣
For three sets: ∣A∪B∪C∣=∣A∣+∣B∣+∣C∣−∣A∩B∣−∣A∩C∣−∣B∩C∣+∣A∩B∩C∣
General Formula
i=1⋃nAi=i∑∣Ai∣−i<j∑∣Ai∩Aj∣+i<j<k∑∣Ai∩Aj∩Ak∣−⋯Example: Derangements
Number of permutations of n elements with no fixed point:
For n=4: D4=4!(0!1−1!1+2!1−3!1+4!1)=24(1−1+21−61+241)=9.
✅ Practice Questions
Q1: How many integers from 1 to 100 are divisible by 2 or 3?
Solution∣A∣=⌊100/2⌋=50 (divisible by 2) ∣B∣=⌊100/3⌋=33 (divisible by 3) ∣A∩B∣=⌊100/6⌋=16 (divisible by 6) ∣A∪B∣=50+33−16=67 Q2: Prove that among any n+1 integers from {1,…,2n}, one divides another. SolutionWrite each number as 2k×m where m is odd. There are only n odd numbers in {1,…,2n}. By pigeonhole, two numbers share the same odd part; the smaller divides the larger. Join Discord PreviousAdvanced PermutationsNextRecurrence Relations