Discrete MathematicsPigeonhole, Inclusion-Exclusion and Generating Functions1 of 4
Pigeonhole, Inclusion-Exclusion and Generating Functions · 1

The Pigeonhole Principle

Sometimes we want to be 100 percent certain that two things in a group match, even when we cannot inspect them one by one.

1

The Pigeonhole Principle

To guarantee that at least two items end up in the same category, we compare the number of items we are placing against the number of categories available to hold them.

5th marble\htmlClass{lc-orange}{5\text{th}}\text{ marble}
4 boxes\htmlClass{lc-blue}{4}\text{ boxes}
The Pigeonhole Principle
no two in the same box\text{no two in the same box}
Text solution
Count the hair-count boxesInclude 0\boxes{0} for a completely bald head up to the maximum of 1,000,000\boxes{1{,}000{,}000} hairs so every possible hair count has its own box.
1,000,000−0+1⏟hair counts from 0 to 1,000,000\displaystyle \underbrace{\boxes{1{,}000{,}000} - \boxes{0} + 1}_{\text{hair counts from } \boxes{0} \text{ to } \boxes{1{,}000{,}000}} =1,000,001 boxes\displaystyle = \boxes{1{,}000{,}001} \text{ boxes}
Fill every box once, then add one more personThe worst-case adversary puts the first 1,000,001\items{1{,}000{,}001} people into all different boxes, so the next person has no empty box left.
1,000,001 boxes+1 person\displaystyle \boxes{1{,}000{,}001} \text{ boxes} + \leftover{1} \text{ person} =1,000,002 people\displaystyle = \guaranteed{1{,}000{,}002} \text{ people}

So with over 8,000,000\items{8{,}000{,}000} people in New York City, at least two people are guaranteed to have the exact same number of hairs on their head.

Now let's try a sock drawer warmup, where we want a matching pair from Black, White, and Gray socks.

Text solution
Put one sock in each color boxSince we want two socks to match by color, the 3\boxes{3} colors are the boxes, and the worst-case adversary puts one sock into each box first.
1 Black+1 White+1 Gray\displaystyle 1 \boxes{\text{ Black}} + 1 \boxes{\text{ White}} + 1 \boxes{\text{ Gray}} =3 socks without a pair\displaystyle = \items{3} \text{ socks without a pair}
Draw one more sock to force a pairEvery color box already holds one sock, so the next sock pulled must match one of them.
3+1\displaystyle \items{3} + \leftover{1} =4 socks\displaystyle = \guaranteed{4} \text{ socks}

So pulling 4\guaranteed{4} socks in the dark guarantees a matching pair.

2

Dealing Evenly and the Worst-Case Adversary

Often we want more than just a pair. We want to know how large a pile we are guaranteed when we drop many items into a few boxes, or how many items we must draw to force 5\guaranteed{5} of a kind, even when the boxes have limited supplies.

Dealing Evenly and the Worst-Case Adversary
10 marbles, 3 boxes\htmlClass{lc-pink}{10}\text{ marbles, }\htmlClass{lc-blue}{3}\text{ boxes}
  ⟹  at least ? in one box\implies \text{at least } ? \text{ in one box}

When 10\items{10} marbles are divided among 3\boxes{3} boxes, the division algorithm splits them into even rounds plus a remainder:

10\displaystyle \items{10} =3⏟boxes×3⏟per box+1⏟leftover marble\displaystyle = \underbrace{\boxes{3}}_{\text{boxes}} \times \underbrace{3}_{\text{per box}} + \underbrace{\leftover{1}}_{\text{leftover marble}}

That leftover marble has to land somewhere, pushing at least one box from 33 up to 4\guaranteed{4}. In shorthand, we write this guaranteed box size with ceiling brackets, which simply mean "divide evenly, and if there is any remainder at all, round up to the next whole number":

⌈103⌉⏟round 3.3‾ up\displaystyle \underbrace{\left\lceil \frac{\items{10}}{\boxes{3}} \right\rceil}_{\text{round } 3.\overline{3} \text{ up}} =4 marbles in at least one box\displaystyle = \guaranteed{4} \text{ marbles in at least one box}

In any arrangement of 10 marbles across 3 boxes, the fullest box always holds at least 4 marbles, and moving a marble out of a box of 4 only pushes another box up to 4 or more.

No matter how 10 marbles are arranged across 3 boxes, the fullest box always holds at least 4.

When a question flips this around and asks how many socks we must pull to guarantee a target count, we add up the most socks the worst-case adversary can hand us before we win, then add 1\leftover{1}.

Text solution
Stop every color one short of 5 (unlimited supply)To keep all 3\boxes{3} color boxes below 5\guaranteed{5}, the adversary puts at most 44 socks into each box, and the next sock forces a 5th\guaranteed{5\text{th}} of one color.
(4+4+4)+1\displaystyle (4 + 4 + 4) + \leftover{1} =12+1\displaystyle = \items{12} + \leftover{1} =13 socks\displaystyle = \guaranteed{13} \text{ socks}
Use up the unwanted colors first (6 Black, 10 White, 8 Gray; goal: 2 Black)Because White and Gray socks never help us get 2\guaranteed{2} Black socks, the adversary gives us all of the White and Gray socks and 11 Black sock before the next draw must be Black.
(10+8+1)+1\displaystyle (10 + 8 + 1) + \leftover{1} =19+1\displaystyle = \items{19} + \leftover{1} =20 socks\displaystyle = \guaranteed{20} \text{ socks}
Cap any box that runs out early (3 Black, 10 White, 8 Gray; goal: 5 of one color)The adversary tries to put 44 socks into every box, but Black runs out at 3\blocked{3}, leaving White and Gray at 44 each before the next sock forces 5\guaranteed{5} of a kind.
(3+4+4)+1\displaystyle (\blocked{3} + 4 + 4) + \leftover{1} =11+1\displaystyle = \items{11} + \leftover{1} =12 socks\displaystyle = \guaranteed{12} \text{ socks}

So 13\guaranteed{13} socks are needed when every color has plenty, 20\guaranteed{20} when we specifically need 2\guaranteed{2} Black socks, and 12\guaranteed{12} when the Black box runs out at 3\blocked{3}.

3

Slicing Up a Shape

Counting boxes only works when we have separate containers, so what do we do when a problem puts points inside a geometric shape? To guarantee that two out of 5\items{5} darts in a 2-by-22\text{-by-}2 square land within 2\guaranteed{\sqrt{2}} inches of each other, we slice the shape itself into 4\boxes{4} boxes.

22
22
11
11
2\htmlClass{lc-green}{\sqrt{2}}
Slicing Up a Shape
two darts within 2 inches?\text{two darts within } \htmlClass{lc-green}{\sqrt{2}} \text{ inches?}
22
22

Notice how the Pythagorean theorem gives the farthest apart two points in a rectangle of width aa and height bb can ever be, right at opposite corners along the diagonal:

d\displaystyle \guaranteed{d} =a2+b2\displaystyle = \sqrt{a^2 + b^2}
Text solution
Slice the square into 4 boxesWith 5\items{5} darts, splitting the 2-by-22\text{-by-}2 square in half both ways creates 4\boxes{4} smaller 1-by-11\text{-by-}1 squares, so at least one 1-by-11\text{-by-}1 square must catch at least ⌈54⌉=2\lceil \tfrac{\items{5}}{\boxes{4}} \rceil = \guaranteed{2} darts.
5 darts into 4 quadrants  ⟹  at least 2 darts in the same 1-by-1 square\displaystyle \items{5} \text{ darts into } \boxes{4} \text{ quadrants} \implies \text{at least } \guaranteed{2} \text{ darts in the same } 1\text{-by-}1 \text{ square}
Measure the diagonal of one 1-by-1 boxTwo darts inside the same 1-by-11\text{-by-}1 square are farthest apart when they sit at opposite corners of that square.
12+12\displaystyle \sqrt{1^2 + 1^2} =2 inches\displaystyle = \guaranteed{\sqrt{2}} \text{ inches}

So at least two of the 5\items{5} darts must land within 2\guaranteed{\sqrt{2}} inches of each other.

Wherever the 5 darts land in the 2-by-2 square, at least one 1-by-1 quadrant holds two or more darts, keeping the closest pair within that quadrant's diagonal of 2\guaranteed{\sqrt{2}}.

No matter how you spread five darts across a 2-by-2 square, at least two of them share one of the four 1-by-1 quadrants and stay within its diagonal.
4

Pairing Numbers by Their Sum

In our earlier problems, two items matched because they had the same property. What if we pick numbers from 1,2,3,4,5,6,7,81, 2, 3, 4, 5, 6, 7, 8 and want to guarantee that two of our chosen numbers add up to 9\guaranteed{9}? Here, the two numbers do not look alike. Instead, they have to be partners that combine to make 9\guaranteed{9}.

Pairing Numbers by Their Sum
How many picks  ⟹  ?+?=9\text{How many picks} \implies {?} + {?} = \htmlClass{lc-green}{9}
11
22
33
44
55
66
77
88
Text solution
Group the list into sum-of-9 boxesPut each pair of numbers that adds to 9\guaranteed{9} into its own box so that picking both numbers from the same box gives a sum of 9\guaranteed{9}.
{1,8}⏟Box 1,{2,7}⏟Box 2,{3,6}⏟Box 3,{4,5}⏟Box 4  ⟹  4 boxes\displaystyle \underbrace{\{1, 8\}}_{\boxes{\text{Box 1}}}, \quad \underbrace{\{2, 7\}}_{\boxes{\text{Box 2}}}, \quad \underbrace{\{3, 6\}}_{\boxes{\text{Box 3}}}, \quad \underbrace{\{4, 5\}}_{\boxes{\text{Box 4}}} \implies \boxes{4} \text{ boxes}
Pick one per box, then draw one moreThe adversary can safely pick 11 number from each of the 4\boxes{4} boxes without completing any pair, so the next pick must land in a box where its partner was already chosen.
4 boxes+1\displaystyle \boxes{4} \text{ boxes} + \leftover{1} =5 numbers\displaystyle = \guaranteed{5} \text{ numbers}
Add a single-number box if the list is 1 through 9If 99 is added to the list, it has no partner in the list and sits in a 5th\boxes{5\text{th}} box {9}\{9\} by itself, giving the adversary one extra safe pick.
5 boxes+1\displaystyle \boxes{5} \text{ boxes} + \leftover{1} =6 numbers\displaystyle = \guaranteed{6} \text{ numbers}

So picking 5\guaranteed{5} numbers from 11 through 88 (or 6\guaranteed{6} numbers from 11 through 99) guarantees that two of the chosen numbers add up to 9\guaranteed{9}.

5

Handshakes and Mutually Exclusive Boxes

Up to now, we always had more items than boxes. At a party of 5\items{5} people, we want to prove that at least two people have shaken the exact same number of hands, even though the possible handshake counts are 0,1,2,3,\boxes{0, 1, 2, 3}, and 4\boxes{4}, which looks like 5\boxes{5} boxes for 5\items{5} people.

only one can be used\htmlClass{lc-orange}{\text{only one can be used}}
0\htmlClass{lc-blue}{0}
1\htmlClass{lc-blue}{1}
2\htmlClass{lc-blue}{2}
3\htmlClass{lc-blue}{3}
4\htmlClass{lc-blue}{4}
shook hands\text{shook hands}
with no one\text{with no one}
shook hands\text{shook hands}
with everyone\text{with everyone}
Handshakes and Mutually Exclusive Boxes
Prove: 2 people shook\text{Prove: 2 people shook}
the same number of hands\text{the same number of hands}
Text solution
List all possible handshake boxesWith 5\items{5} people at the party, each person can shake hands with anywhere from 0\boxes{0} to 4\boxes{4} other people.
Boxes: 0,1,2,3,4  ⟹  5 total boxes\displaystyle \text{Boxes: } \boxes{0, 1, 2, 3, 4} \implies \boxes{5} \text{ total boxes}
Eliminate one box because Box 0 and Box 4 conflictIf someone is in Box 4\boxes{4}, they shook hands with all 44 other people, so nobody at the party can be in Box 0\blocked{0} with zero handshakes.
5 total boxes−1 locked box\displaystyle \boxes{5} \text{ total boxes} - \blocked{1} \text{ locked box} =4 usable boxes\displaystyle = \boxes{4} \text{ usable boxes}
Place 5 people into the 4 usable boxesWith 5\items{5} people and at most 4\boxes{4} boxes open at the same time, at least one box must hold at least 2\guaranteed{2} people.
5 people into 4 usable boxes  ⟹  at least 2 people share a box\displaystyle \items{5} \text{ people into } \boxes{4} \text{ usable boxes} \implies \text{at least } \guaranteed{2} \text{ people share a box}

So at least two people at the party must have shaken the exact same number of hands.

Connecting anyone to all 4 other people empties Box 0, while keeping anyone in Box 0 blocks Box 4, so at most four handshake boxes can be occupied at once and at least two people always share a box.

Giving anyone a fourth handshake connects them to everyone and empties Box 0, so at most four boxes can hold people at once.
6

Remainders as Boxes

Now what if we can pick any 5\items{5} integers out of infinitely many, and we want to guarantee that two of them have a difference that is a multiple of 4\boxes{4}? There are infinitely many integers, so we cannot make a box for each number. Instead, we use the remainders they leave when divided by 4\boxes{4}.

Remember that every integer a\items{a} divided by 4\boxes{4} leaves a remainder r\boxes{r} in {0,1,2,3}\boxes{\{0, 1, 2, 3\}}, and two integers have a difference divisible by 4\boxes{4} precisely when their remainders match:

a\displaystyle \items{a} =4q+r(r∈{0,1,2,3})\displaystyle = \boxes{4}q + \boxes{r} \quad (\boxes{r} \in \boxes{\{0, 1, 2, 3\}})
Remainders as Boxes
Any 5 integers\text{Any } \htmlClass{lc-pink}{5} \text{ integers}
  ⟹  two differ by a multiple of 4\implies \text{two differ by a multiple of } \htmlClass{lc-blue}{4}
7,    12,    18,    21,    31\htmlClass{lc-pink}{7,\;\; 12,\;\; 18,\;\; 21,\;\; 31}
Text solution
Set up the 4 remainder boxes mod 4Dividing any integer by 4\boxes{4} can only produce one of 4\boxes{4} possible remainders, which act as our boxes.
Boxes (remainders mod 4): 0,1,2,3  ⟹  4 boxes\displaystyle \text{Boxes (remainders mod } \boxes{4}\text{): } \boxes{0, 1, 2, 3} \implies \boxes{4} \text{ boxes}
Sort the 5 integers by their remaindersWith 5\items{5} integers and only 4\boxes{4} remainder boxes, at least two integers must land in the same box; for 7,12,18,21,31\items{7, 12, 18, 21, 31}, both 7\items{7} and 31\items{31} leave remainder 3\boxes{3}.
12≡0,21≡1,18≡2,7≡3,31≡3(mod4)\displaystyle \items{12} \equiv \boxes{0}, \quad \items{21} \equiv \boxes{1}, \quad \items{18} \equiv \boxes{2}, \quad \items{7} \equiv \boxes{3}, \quad \items{31} \equiv \boxes{3} \pmod{\boxes{4}}
Subtract the two integers in the same boxBecause 31\items{31} and 7\items{7} have the same remainder 3\boxes{3}, subtracting them cancels the remainder and leaves a multiple of 4\boxes{4}.
31−7\displaystyle \items{31} - \items{7} =(4×7+3)−(4×1+3)\displaystyle = (\boxes{4} \times 7 + \cancelled{3}) - (\boxes{4} \times 1 + \cancelled{3}) =24\displaystyle = \guaranteed{24} =4×6\displaystyle = \boxes{4} \times 6

So among any 5\items{5} integers, at least two have a difference that is a multiple of 4\boxes{4}.

7

Running Totals and Consecutive Sums

Remainder boxes worked above because subtracting two numbers with the same remainder cancels their remainders. How do we use that subtraction trick when we want a consecutive stretch of numbers in the list 7,9,2,6,37, 9, 2, 6, 3 to add up to a multiple of 5\boxes{5}?

77
99
22
66
33
s5\htmlClass{lc-pink}{s_5}
=27= 27
s1\htmlClass{lc-pink}{s_1}
=7= 7
s5−s1\htmlClass{lc-pink}{s_5} - \htmlClass{lc-pink}{s_1}
=20= \htmlClass{lc-green}{20}
Running Totals and Consecutive Sums
a consecutive stretch adds\text{a consecutive stretch adds}
to a multiple of 5\text{to a multiple of } \htmlClass{lc-blue}{5}
77
99
22
66
33
Text solution
Add the list from left to right to form 5 running totalsMake the items the running totals s1\items{s_1} through s5\items{s_5} so that subtracting an earlier total from a later one leaves a consecutive stretch of the list.
s1\displaystyle \items{s_1} =7,s2\displaystyle = 7, \quad \items{s_2} =16,s3\displaystyle = 16, \quad \items{s_3} =18,s4\displaystyle = 18, \quad \items{s_4} =24,s5\displaystyle = 24, \quad \items{s_5} =27\displaystyle = 27
Rule out Box 0 or win immediatelyWhen dividing by 5\boxes{5}, the remainder boxes are 0,1,2,3,4\boxes{0, 1, 2, 3, 4}; if any running total lands in Box 0\blocked{0}, that running total is already a multiple of 5\boxes{5}, so the adversary must keep Box 0\blocked{0} empty and leave only 4\boxes{4} boxes.
Open remainder boxes mod 5: 1,2,3,4  ⟹  4 usable boxes for 5 running totals\displaystyle \text{Open remainder boxes mod } \boxes{5}\text{: } \boxes{1, 2, 3, 4} \implies \boxes{4} \text{ usable boxes for } \items{5} \text{ running totals}
Find the two running totals in the same remainder boxDropping the 5\items{5} running totals into the 4\boxes{4} open boxes forces a match in Box 2\boxes{2} between s1=7\items{s_1} = 7 and s5=27\items{s_5} = 27.
s1≡2,s2≡1,s3≡3,s4≡4,s5≡2(mod5)\displaystyle \items{s_1} \equiv \boxes{2}, \quad \items{s_2} \equiv \boxes{1}, \quad \items{s_3} \equiv \boxes{3}, \quad \items{s_4} \equiv \boxes{4}, \quad \items{s_5} \equiv \boxes{2} \pmod{\boxes{5}}
Subtract the earlier running total from the later oneChopping s1\items{s_1} off the front of s5\items{s_5} cancels their matching remainder of 2\boxes{2} and leaves the consecutive sum from the 2nd2\text{nd} number through the 5th5\text{th} number.
s5−s1\displaystyle \items{s_5} - \items{s_1} =27−7\displaystyle = 27 - \cancelled{7} =9+2+6+3\displaystyle = \guaranteed{9 + 2 + 6 + 3} =20\displaystyle = \guaranteed{20} =5×4\displaystyle = \boxes{5} \times 4

So the consecutive stretch 9+2+6+3\guaranteed{9 + 2 + 6 + 3} adds up to 20\guaranteed{20}, which is a multiple of 5\boxes{5}.

Key concepts

Every Pigeonhole problem comes down to choosing your boxes (the property you want two or more items to match on) and counting your items against the worst-case adversary.

Basic match (k\boxes{k} boxes, k+1\boxes{k} + \leftover{1} items)

If you have more items than boxes, at least one box holds 2\guaranteed{2} or more items. With 3\boxes{3} sock colors (Black, White, Gray), 3+1=4\boxes{3} + \leftover{1} = \guaranteed{4} socks guarantee a matching pair.

Dealing evenly (⌈Nk⌉\lceil \tfrac{\items{N}}{\boxes{k}} \rceil in one box)

Even when N\items{N} items are spread across k\boxes{k} boxes as evenly as possible, at least one box holds at least ⌈Nk⌉\lceil \tfrac{\items{N}}{\boxes{k}} \rceil items, like 10\items{10} marbles in 3\boxes{3} boxes forcing ⌈103⌉=4\lceil \tfrac{\items{10}}{\boxes{3}} \rceil = \guaranteed{4} in one box. To go in reverse and guarantee m\guaranteed{m} items in the same box when supplies are plentiful, the adversary puts m−1\guaranteed{m} - 1 items in each of the k\boxes{k} boxes first, so you need k(m−1)+1\boxes{k}(\guaranteed{m} - 1) + \leftover{1} items (3×4+1=13\boxes{3} \times 4 + \leftover{1} = \guaranteed{13} socks for 5\guaranteed{5} of one color).

When not to use the even-dealing formula

Don't use ⌈Nk⌉\lceil \tfrac{\items{N}}{\boxes{k}} \rceil or k(m−1)+1\boxes{k}(\guaranteed{m} - 1) + \leftover{1} if a box runs out of items early or if you only care about one specific box. Instead, add up the worst-case draws directly: with 33 Black, 1010 White, and 88 Gray socks, getting 5\guaranteed{5} of a kind takes (3+4+4)+1=12(\blocked{3} + 4 + 4) + \leftover{1} = \guaranteed{12} socks because Black runs out at 3\blocked{3}, and getting 2\guaranteed{2} Black socks takes (10+8+1)+1=20(10 + 8 + 1) + \leftover{1} = \guaranteed{20} socks because the adversary gives you all of the White and Gray socks first.

Hidden boxes (shapes, sum-pairs, handshakes, remainders, running totals)

  • Distance in a shape: Slice the region into boxes whose diagonal a2+b2\guaranteed{\sqrt{a^2 + b^2}} equals the target distance (5\items{5} darts in four 1-by-11\text{-by-}1 squares guarantee two within 2\guaranteed{\sqrt{2}}).
  • Pairs with a target sum: Put each pair that adds to the target into one box, and leave any unpaired number in a box of its own ({1,8}\{1, 8\}, {2,7}\{2, 7\}, {3,6}\{3, 6\}, {4,5}\{4, 5\} plus {9}\{9\} gives 5\boxes{5} boxes, so 6\guaranteed{6} picks from 1–91\text{--}9 force a sum of 9\guaranteed{9}).
  • Mutually exclusive boxes: Check if two extreme boxes cannot both be used (5\items{5} people have handshake boxes 0–4\boxes{0\text{--}4}, but Box 0\boxes{0} and Box 4\boxes{4} contradict each other, leaving 4\boxes{4} usable boxes).
  • Remainders and running totals: For a difference divisible by n\boxes{n}, use the n\boxes{n} remainders 0,1,…,n−1\boxes{0, 1, \dots, n - 1} as boxes (5\items{5} integers mod 4\boxes{4} force a match). For a consecutive sum divisible by n\boxes{n}, make the running totals s1,s2,…,sn\items{s_1, s_2, \dots, s_n} the items and lock Box 0\blocked{0} shut (5\items{5} running totals in open boxes 1,2,3,4(mod5)\boxes{1, 2, 3, 4} \pmod{\boxes{5}} force sj−si\items{s_j} - \items{s_i} to be a multiple of 5\boxes{5}).
8

Practice

1

There are 100 people in a lecture hall. At least how many of them must have been born in the same month?

What are the 12 boxes here, and how many full even rounds can you deal 100 people into them before leftovers appear?

The 12\boxes{12} months are the 12\boxes{12} boxes. Dividing 100\items{100} people evenly across the 12\boxes{12} months gives:
100\displaystyle \items{100} =12×8+4\displaystyle = \boxes{12} \times 8 + \leftover{4}
Dealing as evenly as possible puts 88 people into each of the 12\boxes{12} months (9696 people total), with 4\leftover{4} people left over. Watch out for the common slip of rounding down to 88 or adding all 4\leftover{4} leftover people into the same box to get 8+4=128 + 4 = 12; the adversary spreads those 4\leftover{4} remaining people across 4\boxes{4} different months, pushing those boxes up by just 11:
⌈10012⌉\displaystyle \left\lceil \frac{\items{100}}{\boxes{12}} \right\rceil =9 people\displaystyle = \guaranteed{9} \text{ people}
2

A drawer in a dark room holds 3 brown, 8 black, 10 navy, and 6 gray socks. How many socks must you pull out blindly to be 100 percent sure you have at least 5 socks of the same color?

There are 4 color boxes. How many socks can the worst-case adversary put into each box without giving you 5 of a kind, watching the supply of brown socks?

The 4\boxes{4} colors (brown, black, navy, and gray) are the 4\boxes{4} boxes. To stop you from reaching 5\guaranteed{5} in any box, the adversary tries to give you 44 socks of each color. Don't multiply 4×4+1=174 \times 4 + 1 = 17, which forgets that there are only 3\blocked{3} brown socks in the entire drawer. The brown box runs out at 3\blocked{3}, while black, navy, and gray can each hold 44 safely:
3+4+4+4\displaystyle \blocked{3} + 4 + 4 + 4 =15 socks without 5 of a kind\displaystyle = \items{15} \text{ socks without 5 of a kind}
The next sock must be black, navy, or gray, pushing that box from 44 to 5\guaranteed{5}:
15+1\displaystyle \items{15} + \leftover{1} =16 socks\displaystyle = \guaranteed{16} \text{ socks}
3

How many numbers must you pick from the list 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 to guarantee that two of the numbers you picked add up to 10?

Group the numbers that pair up to make 10 into boxes first, then check which numbers in the list have no partner.

Pair the numbers from the list that add up to 10\guaranteed{10}:
{1,9},{2,8},{3,7},{4,6}\displaystyle \{1, 9\}, \quad \{2, 8\}, \quad \{3, 7\}, \quad \{4, 6\}
Avoid the trap of dividing 1010 numbers by 22 to get 55 boxes and answering 5+1=65 + 1 = 6: the number 55 cannot be picked twice to pair with itself, and 1010 has no 00 in the list to pair with, so {5}\{5\} and {10}\{10\} each sit in their own box. That makes 6\boxes{6} boxes in total:
{1,9},{2,8},{3,7},{4,6},{5},{10}  ⟹  6 boxes\displaystyle \{1, 9\}, \quad \{2, 8\}, \quad \{3, 7\}, \quad \{4, 6\}, \quad \{5\}, \quad \{10\} \implies \boxes{6} \text{ boxes}
The adversary can safely pick 6\items{6} numbers, one from each box, so the next pick is guaranteed to complete one of the four pair-boxes:
6+1\displaystyle \items{6} + \leftover{1} =7 numbers\displaystyle = \guaranteed{7} \text{ numbers}
4

How many integers must you pick to guarantee that at least three of them have pairwise differences that are all multiples of 6?

Two integers have a difference divisible by 6 when they share a remainder mod 6; how many integers can the adversary place into the 6 remainder boxes before one box reaches 3?

Two integers have a difference divisible by 6\boxes{6} if and only if they leave the same remainder when divided by 6\boxes{6}, so there are 6\boxes{6} remainder boxes: 0,1,2,3,4,\boxes{0, 1, 2, 3, 4}, and 5\boxes{5}. To guarantee three integers whose pairwise differences are all multiples of 6\boxes{6}, we need 3\guaranteed{3} integers in the same remainder box. Be careful not to stop at 6+1=76 + 1 = 7 (which only guarantees 22 in the same box) or compute 6×3+1=196 \times 3 + 1 = 19 (which puts 33 per box before adding 11). The adversary can put at most 22 integers into each of the 6\boxes{6} boxes without giving you 3\guaranteed{3} in any box:
6×2\displaystyle \boxes{6} \times 2 =12 integers\displaystyle = \items{12} \text{ integers}
The next integer forces at least one remainder box to hold 3\guaranteed{3} integers:
12+1\displaystyle \items{12} + \leftover{1} =13 integers\displaystyle = \guaranteed{13} \text{ integers}
5

How many darts must you throw into a 6-by-8 inch rectangle to guarantee that at least two darts land within 5 inches of each other, and why?

Slice the 6-by-8 rectangle in half both ways and check the diagonal of each smaller box.

Slice the 6-by-86\text{-by-}8 inch rectangle in half vertically and horizontally to form 4\boxes{4} boxes, each measuring 3-by-43\text{-by-}4 inches. Don't use the side lengths 33 or 44 as the maximum distance inside a box; the farthest apart two darts in the same 3-by-43\text{-by-}4 box can be is at opposite corners along the diagonal:
32+42\displaystyle \sqrt{3^2 + 4^2} =9+16\displaystyle = \sqrt{9 + 16} =25\displaystyle = \sqrt{25} =5 inches\displaystyle = \guaranteed{5} \text{ inches}
Because there are 4\boxes{4} such boxes, throwing one more dart than the number of boxes forces two darts into the same 3-by-43\text{-by-}4 box and within 5\guaranteed{5} inches of each other:
4+1\displaystyle \boxes{4} + \leftover{1} =5 darts\displaystyle = \guaranteed{5} \text{ darts}
6

Seven computers in a lab are wired together with direct cables (no computer is wired to itself, and at most one cable connects any pair). Suppose the first 6 computers all have different numbers of cables attached to them, and one of them is wired to all 6 other computers. Which cable counts do the first 6 computers have, and why must the 7th computer match one of them?

The possible cable-count boxes are 0 through 6; which box is locked shut because one computer is in Box 6?

Among 7\items{7} computers, the possible cable-count boxes are 0,1,2,3,4,5,\boxes{0, 1, 2, 3, 4, 5}, and 6\boxes{6}. Because one computer is in Box 6\boxes{6} (wired to all 66 other computers), every computer in the lab has at least 11 cable attached to it, locking Box 0\blocked{0} shut. Avoid listing 0\blocked{0} among the first six cable counts (such as 0,1,2,3,4,60, 1, 2, 3, 4, 6): since Box 0\blocked{0} is empty and the first 6\items{6} computers all have different counts, they must fill the 6\boxes{6} open boxes:
First 6 computers’ cable counts: 1,2,3,4,5,6\displaystyle \text{First 6 computers' cable counts: } \boxes{1, 2, 3, 4, 5, 6}
Because the 7th\leftover{7\text{th}} computer also cannot be in Box 0\blocked{0}, it must land in one of Boxes 1\boxes{1} through 6\boxes{6} and match the computer already in that box.
7

For the list of 6 numbers 8, 5, 9, 11, 2, 3, find the running totals s1s_1 through s6s_6 and their remainders mod 6, identify the two running totals that land in the same remainder box, and give the consecutive stretch of numbers whose sum is a multiple of 6.

Add the numbers from left to right to get s1s_1 through s6s_6, reduce each sum mod 6, and subtract the earlier matching running total from the later one.

Make sure to take remainders of the running totals rather than the individual numbers:
s1=8≡2(mod6)s2=8+5=13≡1(mod6)s3=13+9=22≡4(mod6)s4=22+11=33≡3(mod6)s5=33+2=35≡5(mod6)s6=35+3=38≡2(mod6)\displaystyle \begin{aligned} \items{s_1} &= 8 &&\equiv \boxes{2} \pmod{\boxes{6}} \\ \items{s_2} &= 8 + 5 = 13 &&\equiv \boxes{1} \pmod{\boxes{6}} \\ \items{s_3} &= 13 + 9 = 22 &&\equiv \boxes{4} \pmod{\boxes{6}} \\ \items{s_4} &= 22 + 11 = 33 &&\equiv \boxes{3} \pmod{\boxes{6}} \\ \items{s_5} &= 33 + 2 = 35 &&\equiv \boxes{5} \pmod{\boxes{6}} \\ \items{s_6} &= 35 + 3 = 38 &&\equiv \boxes{2} \pmod{\boxes{6}} \end{aligned}
None of the running totals lands in Box 0\blocked{0}, so the 6\items{6} running totals share the 5\boxes{5} open boxes 1\boxes{1} through 5\boxes{5}, and both s1=8\items{s_1} = 8 and s6=38\items{s_6} = 38 land in Box 2\boxes{2}. When subtracting s6−s1\items{s_6} - \items{s_1}, watch out for the common slip of keeping the first number 8\cancelled{8} in the consecutive stretch (which would add to 3838 instead of 30\guaranteed{30}); subtracting s1=8\items{s_1} = \cancelled{8} chops the first number off the list and leaves the 2nd2\text{nd} through 6th6\text{th} numbers:
s6−s1\displaystyle \items{s_6} - \items{s_1} =38−8\displaystyle = 38 - \cancelled{8} =5+9+11+2+3\displaystyle = \guaranteed{5 + 9 + 11 + 2 + 3} =30\displaystyle = \guaranteed{30}