High School Mathematics · Grades 10–12
27Combinatorics and Counting
Combinatorics is the art of counting without listing. Its two elementary principles — add the sizes of disjoint alternatives, multiply the numbers of independent choices — suffice to count the arrangements, permutations and subsets of a finite set, and culminate in the binomial theorem.
27.1 The two counting principles
We write for the number of elements (the cardinality) of a finite set .
Proposition 27.1 (Addition principle)
If a finite set is partitioned into subsets (pairwise disjoint, with union ), then
Proposition 27.2 (Multiplication principle)
If an object is built by a succession of choices, with options for the first choice and, whatever the previous choices, options for the -th, then the number of objects built is .
Proof. Both statements are proved by induction on ; the case of the second amounts to counting a rectangular array by rows. ∎
Example 27.3
A restaurant offers 4 starters, 6 mains, 3 desserts: different three-course meals.
27.2 Tuples, permutations, factorials
Definition 27.4 (-tuples)
A -tuple of a set is an ordered list of elements of , repetitions allowed. A -tuple of distinct elements is an arrangement of elements of .
Proposition 27.5
Let . The number of -tuples of is . The number of arrangements of elements of () is
where (and ) is the factorial of .
Proof. Multiplication principle: for a -tuple there are options at each of the steps; for an arrangement, options for , then for (one element is used), …, for . ∎
Definition 27.6 (Permutation)
A permutation of is an arrangement of all elements of : an ordering of . By Proposition 27.5 (case ), the number of permutations of an -element set is .
Example 27.7
Five runners can finish a race in different orders. The number of possible podiums (first three places) is .
27.3 Combinations and binomial coefficients
Definition 27.8 (Combinations)
A combination of elements of is a subset of with elements (no order, no repetition). Their number is written , read “ choose ”.
Theorem 27.9
For :
Proof. Count the arrangements of elements of in two ways. Directly: . Alternatively, choose first the underlying subset ( ways), then order it ( ways); the multiplication principle gives . Equating, . ∎
Proposition 27.10 (Basic identities)
For :
and Pascal’s rule: for ,
Proof. The symmetry holds because taking complements matches -element subsets with -element subsets, one for one. For Pascal’s rule, fix an element and sort the -element subsets into those containing — obtained by adjoining to a -element subset of , of which there are — and those avoiding , which are the -element subsets of , numbering . Conclude by the addition principle. ∎
Pascal’s rule generates the coefficients row by row — Pascal’s triangle: each entry is the sum of the two above it.
Theorem 27.11 (Binomial theorem)
For all (or ) and :
Proof. Expand the product ( factors): each term of the expansion picks or in every factor, producing where is the number of factors contributing . The number of ways to choose these factors among is , which is therefore the coefficient of . ∎
Corollary 27.12
and ().
Proof. Take , then , in the binomial theorem. The first identity also has a direct meaning: an -element set has subsets (each element is in or out: multiplication principle), sorted by size. ∎
Method 27.13 (Choosing the right model)
Before counting, answer two questions: does order matter? and are repetitions allowed?
| order matters | order irrelevant | |
|---|---|---|
| repetitions allowed | (tuples) | (university) |
| no repetitions | (arrangements) | (subsets) |
Drawing balls from an urn: with replacement, in order tuples; without replacement, in order arrangements; a handful all at once subsets.
27.4 Exercises
Exercise 27.1 ★
A license plate consists of 2 letters (A–Z), then 3 digits, then 2 letters. How many plates are possible? How many have no repeated character?
Solution
Solution of Exercise 27.1.
Multiplication principle: .
Without repeated characters, the four letters must be distinct ( ways, filling the letter positions in order) and the three digits distinct ():
Exercise 27.2 ★
Compute , , and simplify .
Solution
Solution of Exercise 27.2.
; ;
Exercise 27.3 ★
In a class of 30 students, one must elect a committee of 4 students, then a president and a treasurer within the committee (one person cannot hold both offices). How many outcomes are possible?
Solution
Solution of Exercise 27.3.
Choose the committee: ways. Then choose president and treasurer among the 4, in order: ways. Total
Exercise 27.4 ★
Expand and using the binomial theorem. What is the coefficient of in ?
Solution
Solution of Exercise 27.4.
In , the term in is : the coefficient is .
Exercise 27.5 ★★
A standard poker hand consists of 5 cards from a 52-card deck.
- How many hands are there?
- How many hands contain exactly one ace? At least one ace?
- How many hands are “full houses” (three cards of one rank, two of another)?
Solution
Solution of Exercise 27.5.
1. .
2. Exactly one ace: choose it ( ways) and complete with non-aces: . At least one ace: complementary counting, .
3. Choose the rank of the three-of-a-kind (), its suits (), the rank of the pair ( remaining), its suits (): .
Exercise 27.6 ★★
How many anagrams (rearrangements of letters, meaningful or not) does the word MATH have? The word BANANA? (Hint for BANANA: first place the three A’s.)
Solution
Solution of Exercise 27.6.
MATH has 4 distinct letters: anagrams.
BANANA has 6 letters: three A’s, two N’s, one B. Choose the positions of the A’s (), then of the N’s among the rest (), the B takes the last spot:
(Equivalently .)
Exercise 27.7 ★★
Prove the identity () in two ways: by the factorial formula, and by counting in two ways the pairs (committee of people, its president) chosen from people.
Solution
Solution of Exercise 27.7.
Algebraically:
By double counting: count pairs (committee of , president in it). Either choose the committee () then its president (): pairs. Or choose the president first ( options) then the other members among the remaining : pairs.
Exercise 27.8 ★★
A path in the plane goes from to by unit steps East or North. Show that the number of such paths is .
Solution
Solution of Exercise 27.8.
A path consists of exactly steps, of which are East and are North; it is entirely determined by the set of instants (among the ) at which one steps East. There are such choices.
Exercise 27.9 ★★★
Prove Vandermonde’s identity: for ,
by counting the -element subsets of a set split into a group of and a group of . Deduce that .
Solution
Solution of Exercise 27.9.
Split a set of people into a group of and a group of . A -element subset contains some number of members of () and members of ; for fixed there are such subsets, and the addition principle over gives Vandermonde’s identity.
With :
using the symmetry .
Exercise 27.10 ★★★
Using the binomial theorem, show that for all ,
(Hint: either differentiate , or use Exercise 27.7.)
Solution
Solution of Exercise 27.10.
Via Exercise 27.7:
by Corollary 27.12. Via differentiation: differentiating gives ; evaluate at .
27.5 Problem: The art of counting twice
Problem 27.1
Weekend problem — stars and bars, deranged hats, and identities proved by counting one thing two ways
The deepest trick in combinatorics is disarmingly simple: count the same collection twice, by two different methods, and equate the answers. This problem practices the models of Method 27.13, adds a technique the chapter’s course did not need — the stars and bars of ice-cream counting — then counts the famous deranged hats exactly, and finds the number waiting at the bottom of the hat pile, its third appearance in this book.
Part I — Choosing the model.
- Count the license plates made of letters followed by digits; then the anagrams of BANANA.
- From a -card deck, count the -card hands; then the hands containing exactly of the aces.
- A robot walks from to using only unit steps right or up: how many paths? (Encode a path as a word in R and U.)
- Expand by the binomial theorem (Theorem 27.11); then evaluate at and : which two identities about the numbers drop out?
- Prove by double counting that (count committees-with-chair two ways), and deduce .
Part II — Stars and bars.
- An ice-cream shop sells flavors; you order scoops (flavors may repeat, order in the cup is irrelevant). Encode an order as a row of stars (scoops) separated by bars (flavor changes), and count the orders.
- Count the triples of nonnegative integers with .
- Count the triples of positive integers with (substitute , etc.).
- How many distinct monomials appear in the expansion of ?
- Sanity check the method: count the orders of scoops from flavors with the formula, then list them all and compare.
- Say exactly where “scoops are identical” entered the encoding — and count what happens instead if the scoops are eaten in order (distinct positions), with Method 27.13’s checklist.
Part III — The deranged hats. A derangement is a redistribution of hats to their owners in which nobody receives their own hat; let count them. (Problem 18.1 showed that one guest on average recovers their own hat — now we count the fully unlucky parties exactly.)
- Compute , , by listing, and patiently (or cleverly).
- Justify the recurrence : guest 1 receives some hat ( choices); split according to whether guest receives hat 1 or not. Check it reproduces , and compute .
- For , prove by inclusion–exclusion (subtract the assignments fixing at least one hat, add back the overcounts) that , and state the general formula.
- Compute and compare with : the probability that a large shuffled party deranges completely is — the third cameo of this constant, after the lottery and the secretary of Problem 23.1. (Why: the formula of question 14 is the beginning of a famous series for , told in the university volumes.)
- Secret Santa among friends: names are drawn uniformly at random. What is the probability the draw is valid (nobody draws themselves), and how many redraws should the group expect?
Part IV — Counting twice, winning twice.
- The handshake lemma: at any party, summing over guests the number of hands each shook counts every handshake exactly twice. Deduce that the number of guests who shook an odd number of hands is always even — and check the claim makes sense at a three-guest party.
- Prove the jewel by induction, and verify it for . (Little Gauss’s sum, squared, counts cubes.)
- Vandermonde’s identity (Exercise 27.9) via paths: interpret as lattice paths of question 3’s kind from to , cut each path at its crossing of the anti-diagonal, and explain how appears.
- Finale — the counter’s four moves, one line each with an example from this problem: multiply stages and add cases; encode cleverly (stars and bars, path words); count the same thing twice (committee-with-chair, handshakes); subtract the unwanted and correct the overcounts (derangements). And note where the counting goes to work next: probability, and the paths of the matrices-and-graphs chapter.
Solution
Solution of Problem 27.1.
1. plates. BANANA: letters with A tripled and N doubled: anagrams.
2. hands; with exactly two aces.
3. A path is a word with R’s and U’s: choose the U positions: .
4. . At : ; at : — row sums and alternating row sums of Pascal’s triangle.
5. Committees of people with a chair, from : choose the committee then its chair (), or the chair then the other members (): equal. Summing over : the right side sums to .
6. A row of stars and bars encodes the order (scoops of flavor 1 before the first bar, etc.); the row has symbols and is determined by the bar positions: orders.
7. stars, bars: .
8. With and : .
9. A monomial with : .
10. Formula: stars, bar: ; list: , , , : agreement.
11. “Identical” entered when an order was declared to be nothing but the counts per flavor — the stars carry no names. If the scoops are eaten in order, each of the distinct positions picks a flavor freely: sequences — a different model and a different world (Method 27.13: always ask ordered? distinct? repetition allowed?).
12. ; (swap); (the two -cycles); .
13. Guest 1 gets hat : choices. If guest gets hat 1, the remaining guests derange their own hats: ways. If guest does not get hat 1, relabel hat 1 as guest ’s forbidden hat: the remaining guests derange: ways. Hence . Check: ; and .
14. Of the assignments, subtract those fixing at least one hat: three fix a given hat ( each, ), overcounting the pairs ( pairs, each) which must return, and re-subtracting the identity (): , i.e. . In general .
15. , already close to : the alternating sum marches to . A large party’s hats derange about of the time — the lottery’s and the secretary’s constant, third sighting.
16. . Each redraw succeeds with probability , so the expected number of draws is about : budget three hat-passings.
17. Each handshake contributes to the total degree count, so the sum of all guests’ handshake-numbers is even. A sum of integers is even only if the number of odd terms is even: odd-shakers come in even numbers. (At three guests: possible handshake profiles never have exactly one or three odd entries — check the four possible graphs.)
18. : . If , adding :
heredity. For : .
19. A path to makes steps and crosses the anti-diagonal at exactly one lattice point ; the first half is a path with R’s among steps ( choices), the second half, read backwards, likewise ( again, by symmetry). Summing over the crossing point: — Vandermonde’s identity, drawn.
20. Multiply stages, add cases: plates and poker hands. Encode: paths as RU-words, orders as stars and bars. Count twice: committees-with-chair, handshakes, mid-cut paths. Subtract and correct: the deranged hats, with as the residue. Next stops: these counts under probability’s fractions, and the path-counting powers of the adjacency matrices two chapters ahead.