Discrete Mathematics · Unit 1 · Topic 06

Pigeonhole principle: more pigeons than holes.

Short answer

If \(n + 1\) objects go into \(n\) boxes, some box gets at least two. More generally, \(N\) objects in \(k\) boxes put at least \(\left\lceil \dfrac{N}{k} \right\rceil\) objects in some box.

Example: among 13 people, two share a birth month. Among 50 people, at least \(\lceil 50/12 \rceil = 5\) share one.

EngineeringComputer Science / ITBSc
01

The principle and why it is true

Before you start: you only need to count. For a warm-up, revise permutations and combinations.

Put 10 letters into 9 pigeonholes. However you do it, some pigeonhole gets at least two letters. That obvious fact proves surprising things, because it tells you something must happen without telling you where.

Pigeonhole principle

If \(n + 1\) or more objects are placed into \(n\) boxes, at least one box contains two or more objects.

Generalised form

If \(N\) objects are placed into \(k\) boxes, at least one box contains at least \[\left\lceil \frac{N}{k} \right\rceil \text{ objects.}\]

The "how many do I need" form

To be sure that some box has at least \(r + 1\) objects, you need \(N = kr + 1\) objects. With \(kr\) objects you can still put exactly \(r\) in every box.

\(\lceil x \rceil\) is the ceiling of \(x\): the smallest integer \(\ge x\). So \(\lceil 4.17 \rceil = 5\) and \(\lceil 4 \rceil = 4\).

Why it works. Suppose every box had fewer than \(\lceil N/k \rceil\) objects. Then every box has at most \(\lceil N/k \rceil - 1\), which is less than \(N/k\). Adding up the \(k\) boxes gives fewer than \(k \cdot \dfrac{N}{k} = N\) objects. But there are \(N\). That contradiction is the whole proof.

The principle is also called Dirichlet's box principle. It proves that something exists; it never tells you which box, or which pair, it is.

02

How to choose the pigeons and the holes

  1. Read what you must prove. "Two of them share a property" is the usual signal.
  2. Holes = the possible values of that property. Months, remainders, colours, small regions, pairs.
  3. Pigeons = the things you are given. People, numbers, socks, points.
  4. Count both. If pigeons > holes, two pigeons share a hole. For "at least \(r + 1\)", check that pigeons \(\ge kr + 1\).
  5. Translate back. Two numbers in the same remainder hole have a difference divisible by \(n\); two points in the same small square are close; and so on.
Problem typePigeonsHoles
Shared birth monthpeople12 months
Matching sockssocks drawncolours
Difference divisible by \(n\)integersremainders \(0, 1, \ldots, n - 1\)
Two close pointspointsequal small regions
Two numbers with a given sumchosen numberspairs that add up to that sum
A block whose sum is divisible by \(n\)prefix sumsremainders mod \(n\)

The hard part is always the holes. They must cover every case, and two pigeons in one hole must give you exactly what the question asks for.

03

Solved examples

Example 1: Birth months

Easy

Show that in any group of 13 people, two were born in the same month. In a group of 50 people, how many at least must share a birth month?

  1. Pigeons: people. Holes: the 12 months.
  2. 13 people, 12 months: \(13 > 12\), so two people share a month.
  3. For 50 people: \(\left\lceil \dfrac{50}{12} \right\rceil = \lceil 4.17 \rceil = 5\).
  4. Check that 4 is not forced too high: with 4 per month you can place only \(12 \times 4 = 48 < 50\) people, so some month has 5.

Answer13 people force a shared month; among 50 people, at least 5 share a birth month.

Example 2: Minimum class size

Easy

Students are graded A, B, C, D or E. What is the smallest class size that guarantees at least 6 students get the same grade?

  1. Holes: \(k = 5\) grades. We want some hole to have \(r + 1 = 6\), so \(r = 5\).
  2. \(N = kr + 1 = 5 \times 5 + 1 = 26\).
  3. 25 is not enough: exactly 5 students per grade gives 25 students with no grade used 6 times.

Answer26 students

Example 3: Socks in the dark

Medium

A drawer has 10 black, 10 white and 10 blue socks, all mixed up. In the dark, how many socks must you take out to be sure of (a) a matching pair, (b) two black socks?

  1. (a) Holes: 3 colours. With 3 socks you could have one of each colour. The 4th sock must match one of them, so 4 socks are enough.
  2. (b) This one is a worst-case count, not a direct pigeonhole. The worst luck is all 20 non-black socks first.
  3. After those 20, the next 2 socks are both black. With 21 socks you might have only one black.

Answer(a) 4 socks; (b) 22 socks

Example 4: Equal remainders

Medium

Show that among any 6 integers, two have a difference divisible by 5.

  1. Holes: the remainders on division by 5, namely \(0, 1, 2, 3, 4\). That is 5 holes.
  2. Pigeons: the 6 integers. \(6 > 5\), so two of them, say \(a\) and \(b\), leave the same remainder \(r\).
  3. Then \(a = 5p + r\) and \(b = 5q + r\), so \(a - b = 5(p - q)\).
  4. 5 integers are not enough: \(0, 1, 2, 3, 4\) have no difference divisible by 5.

AnswerTwo of the six leave the same remainder, so their difference is a multiple of 5.

Example 5: A pair with a given sum

Medium

Six numbers are chosen from \(\{1, 2, \ldots, 10\}\). Show that two of them add up to 11.

  1. Make the holes the pairs that add to 11: \(\{1, 10\}, \{2, 9\}, \{3, 8\}, \{4, 7\}, \{5, 6\}\). These 5 pairs use every number from 1 to 10 exactly once.
  2. Six chosen numbers in 5 pairs: two chosen numbers fall in the same pair.
  3. Those two add up to 11.
  4. Five numbers can avoid it: \(1, 2, 3, 4, 5\) has no two adding to 11.

AnswerTwo of the six chosen numbers always add up to 11.

Example 6: Points in a square

Medium

Five points are placed inside or on a square of side 2. Show that two of them are at most \(\sqrt{2}\) apart.

  1. Cut the square into 4 small squares of side 1 by joining the midpoints of opposite sides. These are the holes.
  2. 5 points, 4 small squares: two points lie in the same small square (a point on a dividing line can go in either square).
  3. The longest distance inside a square of side 1 is its diagonal, \(\sqrt{1^2 + 1^2} = \sqrt{2}\).
  4. So those two points are at most \(\sqrt{2}\) apart. Four points are not enough: the four corners are 2 apart or more.

AnswerSome two of the five points are within \(\sqrt{2}\) of each other.

Example 7: A block divisible by n

Exam level

Show that for any \(n\) integers \(a_1, a_2, \ldots, a_n\), some block of consecutive terms \(a_{i+1} + \cdots + a_j\) has a sum divisible by \(n\). Find such a block for \(3, 8, 6, 2, 9\) with \(n = 5\).

  1. Pigeons: the prefix sums \(S_1 = a_1,\ S_2 = a_1 + a_2,\ \ldots,\ S_n = a_1 + \cdots + a_n\). There are \(n\) of them.
  2. If some \(S_j\) is divisible by \(n\), the block \(a_1 + \cdots + a_j\) works and we are done.
  3. Otherwise every remainder is one of \(1, 2, \ldots, n - 1\): only \(n - 1\) holes for \(n\) sums. So two sums \(S_i\) and \(S_j\) with \(i < j\) leave the same remainder.
  4. Then \(S_j - S_i = a_{i+1} + \cdots + a_j\) is divisible by \(n\).
  5. For \(3, 8, 6, 2, 9\): the prefix sums are \(3, 11, 17, 19, 28\), with remainders \(3, 1, 2, 4, 3\) on division by 5.
  6. \(S_1\) and \(S_5\) both leave remainder 3, so the block is \(a_2 + a_3 + a_4 + a_5 = 8 + 6 + 2 + 9 = 25\).

AnswerThe block \(8 + 6 + 2 + 9 = 25\), which is divisible by 5.

Example 8: One divides another

Exam level

Show that if \(n + 1\) numbers are chosen from \(\{1, 2, \ldots, 2n\}\), one of them divides another.

  1. Write every number as \(2^k \times m\) with \(m\) odd. For example \(12 = 2^2 \times 3\) and \(7 = 2^0 \times 7\).
  2. Holes: the possible odd parts \(m = 1, 3, 5, \ldots, 2n - 1\). There are \(n\) of them.
  3. \(n + 1\) chosen numbers, \(n\) odd parts: two chosen numbers \(2^a m\) and \(2^b m\) share the same \(m\), with \(a < b\).
  4. Then \(2^b m = 2^{b-a} \times 2^a m\), so the smaller divides the larger.
  5. \(n\) numbers are not enough: in \(\{n + 1, \ldots, 2n\}\) the ratio of any two is less than 2, so neither divides the other.

AnswerTwo chosen numbers have the same odd part, and the smaller one divides the larger.

Vipul Sir's tip

Before you write anything, fill in this sentence: "The pigeons are ___ and the holes are ___." If you can't fill both blanks, you haven't found the argument yet. In most exam questions, the holes are remainders, pairs or small regions.

04

Common mistakes

1. Rounding \(N/k\) down

For 50 people and 12 months, \(50/12 \approx 4.17\). The answer is \(\lceil 4.17 \rceil = 5\), not 4. Always round up; if \(N/k\) is a whole number, it stays as it is.

2. Answering \(kr\) instead of \(kr + 1\)

To force 3 people with the same birth month, 24 people is not enough: two per month uses all 24. You need \(12 \times 2 + 1 = 25\).

3. Holes that don't match the question

For "two numbers from 1 to 10 add up to 11", the holes \(\{1, 2\}, \{3, 4\}, \ldots\) are useless: two numbers in \(\{1, 2\}\) add to 3. Build the holes so that two pigeons in one hole give exactly the property you want, here the pairs \(\{1, 10\}, \{2, 9\}, \ldots\).

05

Practice questions

Try each one on paper before you open the answer.

Q1How many people are needed to guarantee that at least 3 share a birth month?

\(k = 12\), \(r + 1 = 3\): \(N = 12 \times 2 + 1 = 25\).

Q2How many cards must be drawn from a standard 52-card deck to guarantee 3 cards of the same suit?

4 suits, \(r = 2\): \(4 \times 2 + 1 = 9\) cards. With 8 cards you could have exactly 2 of each suit.

Q3Show that among any 8 integers, two leave the same remainder when divided by 7.

There are 7 possible remainders \(0, \ldots, 6\) and 8 integers, so two integers share a remainder.

Q4Seven numbers are chosen from \(\{1, 2, \ldots, 12\}\). Show that two of them are consecutive.

Holes: \(\{1, 2\}, \{3, 4\}, \ldots, \{11, 12\}\), 6 pairs. Seven numbers in 6 pairs: two lie in the same pair, and they are consecutive.

Q5Five points with integer coordinates are given in the plane. Show that the midpoint of some two of them also has integer coordinates.

Holes: the parity pattern of \((x, y)\): (even, even), (even, odd), (odd, even), (odd, odd). Five points, 4 patterns: two points share a pattern. Then \(x_1 + x_2\) and \(y_1 + y_2\) are both even, so the midpoint \(\left(\dfrac{x_1 + x_2}{2}, \dfrac{y_1 + y_2}{2}\right)\) has integer coordinates.

Q6In a network of 6 computers, each computer is directly connected to some of the others. Show that two computers have the same number of connections.

Each count is one of \(0, 1, \ldots, 5\): six values. But 0 and 5 can't both happen: a computer joined to all 5 others leaves no computer with 0 connections. So only 5 values are possible for 6 computers, and two computers share a value.

Stuck on a question?

Bring it to a free demo class and work through it with Vipul Sir. Book on WhatsApp.

06

Frequently asked questions

What is the pigeonhole principle?

If more than \(n\) objects go into \(n\) boxes, some box holds at least two objects. It is a counting argument that proves something must happen without saying exactly where.

What is the formula for the generalised pigeonhole principle?

If \(N\) objects go into \(k\) boxes, some box has at least \(\lceil N/k \rceil\) objects. Equivalently, \(kr + 1\) objects force some box to have at least \(r + 1\).

How do I know what the pigeons and holes are?

The pigeons are the objects you are given (people, numbers, points). The holes are the possible values of the property you want two of them to share (months, remainders, regions). Check that two pigeons in one hole give exactly what the question asks for.

Is the pigeonhole principle the same as Dirichlet's principle?

Yes. It is also called Dirichlet's box principle or the drawer principle. The statement is the same.

Related lessons

← All 10 Discrete Mathematics topics
Vipul Sir
Written by Vipul Sir

Vipul Sir has taught mathematics for over 15 years to HSC, CBSE, ICSE, IGCSE/IB, Diploma, Engineering and BSc students at VVS Classes in Goregaon and Vile Parle, Mumbai. He teaches every class himself, concepts first and exam technique second.

Discrete Mathematics

Get Discrete Mathematics right, with Vipul Sir beside you.

Concept-first classes in small batches in Goregaon and Vile Parle, or online. Your first class is free.

WhatsApp↗