CSCA67 Worksheet – Pigeon Hole Principle and Practice
Pigeon Hole Principle.
If n items are put into m containers, with n > m, then at least one
container must contain more than one item.
Example.
Show that given a set of n positive integers, there exists a non-empty subset whose sum is divisible
by n.
Proof done together in class:
Let the n integers be denoted by a1 , a2 , . . . , an . Form the n sums
S1 = a1 (1)
S2 = a1 + a2 (2)
..
. (3)
Sn = a1 + a2 + . . . + an (4)
(5)
If one of these sums is divisible by n, then we are done. Otherwise, by the pigeonhole principle, at
least two of the sums must have the same remainder when divided by n (since only n − 1 distinct
remainders are possible). Pick two such sums Si and Sj , with j > i. Then it follows that
Sj − Si = ai+1 + · · · + aj
must be divisible by n.
Example. Ten points are placed within a unit (this means the side length is 1) equilateral (all
three sides have the same length) triangle. Show that there exist two points with distance is at
most 13 apart. HINT: How many identical subspaces do you want to split the triangle into?
1
Notice that each inner triangle has side length 13 . Since there are 9 of them by pigeon there must
be one with two points in it and those points can be at most distance 31 .
Example. Charlie has a drawer full of 12 red and 14 green socks. In order to avoid waking his
roommate, he must grab a selection of clothes in the dark and get dressed in the hallway. How
many socks must he grab to be assured of having a matching pair?
Solution.
Pigeons: socks
Holes: colours
He needs 3 socks.
Example. In a round-robin tournament of n players, every player plays every other player exactly
once. Prove that if no player goes undefeated, at the end of the tournament there must be two
players with the same number of wins.
Solutions.
If there are n players then each player plays n − 1 games. If they play n − 1 games and no player
wins them all then the most a player can win is n − 2 games.
Pigeons: n players
Holes: The number of wins a player has, which ranges from 0 to n − 1 so n − 1 holes.
Therefore, two players must have the same number of wins.
Q. Why won’t this work if a player is allowed to go undefeated?
A. Then there would be n holes and n players.
Example. Given any 7 different integers, prove that there must exist a pair whose sum or differ-
ence is a multiple of 10. HINT: Look at the 1s digit...
Solution.
Lets consider how we can sum numbers so that they are multiples of 10. First consider the combi-
nations of 1’s digits that sum or subtract to 0 (ie the number is a multiple of 10):
(0) ⇒ 0 + / − 0
(1, 9, -1, -9) ⇒ 1 + 9, 1 − 1, 9 − 9
(2, 8, -2, -8) ⇒ 2 + 8, 2 − 2, 8 − 8
(3, 7, -3, -7) ⇒ 3 + 7, 3 − 3, 7 − 7
2
(4, 6, -4, -6) ⇒ 4 + 6, 4 − 4, 6 − 6
(5, -5) ⇒ 5 + 5
and notice that if each of these categories are the holes (look at the ones digit of a number and put
it in the correct box), then the pigeons are the 7 numbers. There are 6 categories so two numbers
are in one box and we can either sum them or subtract them to get a multiple of 10.
Example. Explain why in a class of 36 students, at least two were born on the same day of the week.
Solution.
Make each day of the week a container, then there are 7. That means that by the generalized PHP
there is at least 6 in one of the 7 boxes (7 × 5 = 35 < 36).
This problem illustrates the Generalized Pigeon Hole Principle.
Generalized Pigeon Hole Principle.
If n items are put into m containers, with n > m(r − 1), then at least one container must
contain at least r items.
In the previous example then, we had n = 36 , m = 7 and since n = 36 > m(r − 1 ) = 7(6−1) = 35
so r = 6 .
Example. A website displays an image each day from an image bank of 30 images. In any given
100-day period, show that some image must be displayed four times.
Solution.
Holes: The 30 images.
Pigeons: the 100 days.
Then notice that 30(4 − 1) = 30(3) = 90 < n so by the GPHP there are at least 4 days with the
same image.
3
Definition: GRAPH.
A Graph G = (V, E) consists of a set V of vertices of size n (think of vertices as objects)
and a set E of edges of size m joining pairs of vertices.
1 4
For example, the graph G with V = {1, 2, 3, 4} and
E = {(1, 2), (1, 4), (2, 3), (3, 4)} can be drawn as follows where
points represent vertices and lines represent edges.
2 3
Example. Let G be a graph with 6 vertices such that every pair of vertices has an edge between
them. Let V = {a, b, c, d, e, f } be the vertices. Draw the graph.
1 6
2 5
3 4
Q. How many edges should your graph have? A. 15
Q. Suppose that some edges are coloured red and the rest blue. Show that there must be some
triangular (three edges forming a triangle) of the same colour.
A. Pick a vertex (doesn’t matter which one, say vertex 1). There are 5 edges, so by pigeon hole,
three or more of the edges have to have the same colour, suppose that colour is red and that the
three (or more vertices) are vertex numbers 4, 5, 6. Consider these three vertices, if they form an
all blue triangle then we are done. If not, then one of their edges is red and so that edge along with
vertex 1 forms a red triangle.
1 6
2 5
3 4