Monocurl Essays
Series Download

Permutations and combinations: counting without listing

Five runners and three medals give 60 podiums but only 10 groups of medalists. The product rule, permutations and combinations, each one proved.

20 min·High school·

All 60 possible podiums for five runners, each written gold, silver, bronze. They are then sorted so that every row holds the same three runners. Ten rows form, with six podiums in each.
Monocurl source
let cx = |c| (c - 2.5) * 1.12
let row_y = |r| 1.9 - r * 0.345
let START = map(range(0, 60), |i| [cx(i - (i // 6) * 6), row_y(i // 6), 0])
var seen = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
var ends = []
for (i in range(0, 60)) {
    let c = committee_of(PODIUMS[i])
    ends .= [cx(seen[c]) + 0.3, row_y(c), 0]
    seen[c] = seen[c] + 1
}
let END = ends
let Cards = |t| map(range(0, 60), |i| Card(lerp(START[i], END[i], t), PODIUMS[i], 0.33, 0.3, 0.9))
mesh title = center{[0, -1.72, 0]} Cap("every podium: gold, silver, bronze", 0.85, INK)
mesh cards = Cards(t: 0)
mesh sets = []

slide "sort"
    play Wait(1.2)
    title = []
    cards.t = 1
    play [Fade(0.5, [&title]), Lerp(3.2, [&cards])]
    sets = [
        map(range(0, 10), |c| center{[-3.33, row_y(c), 0]} Cap(str_join(map(COMMITTEES[c], |x| NAMES[x])), 0.72, SLATE)),
        center{[0, -1.72, 0]} Math("60 \text{ podiums} = 10 \text{ groups} \times 6 \text{ orders}", 0.95, INK)
    ]
    play Fade(0.7, [&sets])
    play Wait(2.2)

Uses the shared definitions for this lesson's figures.

Five runners, A, B, C, D and E, line up for a final. Here are two questions about how it can end. Gold, silver and bronze medals are awarded, so how many different podiums are possible? And the top three also qualify for the next round, where nobody cares in what order they finished today, so how many different groups of three qualifiers are possible?

Both can be answered by writing out a list, and it is worth starting one to see what goes wrong. ABC, ABD, ABE, ACB, and by the twentieth entry you are no longer sure whether ADB is already there. The answers are 60 and 10. A list that long is easy to get wrong and tells you nothing about what happens with eight runners, or with fifty-two cards. We want a way to get both numbers, and the factor of 6 between them, without listing anything.

Two medals first

Start with a smaller race for medals: gold and silver only. Gold can go to any of the 5 runners. Once it has, silver can go to any of the 4 who are left. Lay the outcomes out with one row for each gold medalist.

The 20 ways to award gold and silver to five runners, one row for each gold medalist. The rows list different silver medalists, but every row has exactly four entries, so the total is 5 rows of 4.
The 20 ways to award gold and silver to five runners, one row for each gold medalist. The rows list different silver medalists, but every row has exactly four entries, so the total is 5 rows of 4.
Monocurl source
let ry = |a| 1.08 - a * 0.66
let cx = |j| -1.55 + j * 1.05
mesh heads = [
    center{[-3.1, 1.66, 0]} Note("gold", 0.74),
    center{[cx(1.5), 2.0, 0]} Note("silver: which of the four others", 0.74),
    map(range(0, 4), |j| center{[cx(j), 1.66, 0]} Math(["\text{1st}", "\text{2nd}", "\text{3rd}", "\text{4th}"][j], 0.72, SLATE))
]
mesh rows = map(range(0, 5), |a| [
    Tile([-3.1, ry(a), 0], a, 0.44, 0.44, 0.85, 1),
    Seg([-2.75, ry(a), 0], [-2.25, ry(a), 0], MIST, 2),
    map(range(0, 4), |j| Card([cx(j), ry(a), 0], [a, others([a])[j]], 0.38, 0.4, 0.8))
])
mesh panel = [
    center{[2.9, 0.75, 0]} Math("5 \text{ rows}", 0.9, INK),
    center{[2.9, 0.2, 0]} Math("\times\ 4 \text{ in each}", 0.9, INK),
    center{[2.9, -0.45, 0]} Math("= 20", 1.2, LEAF)
]

Uses the shared definitions for this lesson's figures.

There are 5 rows with 4 entries each, so there are $5 \times 4 = 20$ outcomes. Look at what the multiplication used. The rows do not contain the same silver medalists: row A lists B, C, D, E, and row B lists A, C, D, E. What the rows share is their length, and their length is all that the count needs.

Pause and try

Now add the bronze medal. Predict the number of podiums, and say what has to be true of the 20 gold and silver outcomes for your method to be justified.

Show answerHide answer

Each of the 20 gold and silver outcomes leaves 3 runners for bronze. Which three depends on the outcome, but there are always exactly three. So the podiums form 20 rows of 3, and there are $20 \times 3 = 60$.

The product rule

The same count can be drawn as a tree, where each level is one decision.

  1. Any of the 5 runners can take gold, so the tree starts with 5 branches.
  2. Whoever took gold, 4 runners are left for silver. Every branch splits in 4, which gives 5 × 4 = 20.
  3. Whoever took gold and silver, 3 runners are left for bronze. Each of the 20 branches splits in 3.
  4. A podium is one route from the top to a leaf. This route is gold C, silver A, bronze E.
The tree of choices for a podium. Every runner can take gold, each gold medalist leaves four runners for silver, and each gold and silver pair leaves three for bronze. The 60 leaves are the 60 podiums.
Monocurl source
let X0 = -2.55
let X1 = 3.6
let YS = [1.82, 0.98, -0.02, -1.0]
let x1 = |a| X0 + (a + 0.5) * (X1 - X0) / 5
let x2 = |i| X0 + (i + 0.5) * (X1 - X0) / 20
let x3 = |i| X0 + (i + 0.5) * (X1 - X0) / 60
let ROOT = [(X0 + X1) / 2, YS[0], 0]
let Level1 = block {
    for (a in range(0, 5)) {
        . Seg(ROOT, [x1(a), YS[1], 0], SLATE, 1.5)
    }
    for (a in range(0, 5)) {
        . Tile([x1(a), YS[1], 0], a, 0.36, 0.36, 0.8)
    }
    . Pt(ROOT, INK, 0.07)
    . center{[-3.15, YS[1], 0]} Note("gold", 0.74)
}
let Level2 = block {
    for (a in range(0, 5)) {
        for (j in range(0, 4)) {
            . Seg([x1(a), YS[1] - 0.2, 0], [x2(a * 4 + j), YS[2] + 0.15, 0], SLATE, 1.5)
            . Tile([x2(a * 4 + j), YS[2], 0], others([a])[j], 0.26, 0.28, 0.7)
        }
    }
    . center{[-3.15, YS[2], 0]} Note("silver", 0.74)
}
let Level3 = block {
    for (a in range(0, 5)) {
        for (j in range(0, 4)) {
            let b = others([a])[j]
            for (m in range(0, 3)) {
                let i = a * 12 + j * 3 + m
                . Seg([x2(a * 4 + j), YS[2] - 0.15, 0], [x3(i), YS[3] + 0.12, 0], SLATE, 1)
                . center{[x3(i), YS[3], 0]} fill{COLS[others([a, b])[m]]} stroke{COLS[others([a, b])[m]], 1} Rect([0.07, 0.22])
            }
        }
    }
    . center{[-3.15, YS[3], 0]} Note("bronze", 0.74)
}
mesh hi = []
mesh l1 = []
mesh l2 = []
mesh l3 = []
mesh tally = []

slide "Any of the 5 runners can take gold, so the tree starts with 5 branches."
    l1 = Level1
    tally = center{[0.5, -1.75, 0]} Math("5", 1.1, INK)
    play Fade(0.7)

slide "Whoever took gold, 4 runners are left for silver. Every branch splits in 4, which gives 5 × 4 = 20."
    tally = []
    play Fade(0.3, [&tally])
    l2 = Level2
    tally = center{[0.5, -1.75, 0]} Math("5 \times 4 = 20", 1.1, INK)
    play Fade(0.7)

slide "Whoever took gold and silver, 3 runners are left for bronze. Each of the 20 branches splits in 3."
    tally = []
    play Fade(0.3, [&tally])
    l3 = Level3
    tally = center{[0.5, -1.75, 0]} Math("5 \times 4 \times 3 = 60", 1.1, INK)
    play Fade(0.7)

slide "A podium is one route from the top to a leaf. This route is gold C, silver A, bronze E."
    hi = [
        Path([ROOT, [x1(2), YS[1], 0], [x2(8), YS[2], 0], [x3(26), YS[3], 0]], INK, 5),
        Ring([x3(26), YS[3] - 0.02, 0], INK, 0.17, 3)
    ]
    play Fade(0.6, [&hi])

Uses the shared definitions for this lesson's figures.

Each level multiplies the number of branches by the number of options at that level, and it can do so because every branch at one level splits into the same number of branches at the next. Stated with care, the principle is this.

For the two medals, $S$ is the set of pairs (gold, silver), with $m = 5$ and $n = 4$. The phrase “each of them is paired with exactly $n$” is the equal row lengths. The theorem does not ask the second entries to be the same from row to row.

The rule extends to any number of decisions. A podium is a triple, and we can regard it as a pair whose first entry is the (gold, silver) outcome and whose second entry is the bronze medalist. There are 20 first entries, each paired with exactly 3 second entries, so there are 60 triples. Repeating this, a process of $k$ decisions with $n_1$ options for the first, $n_2$ for the second whatever the first was, and so on, has $n_1 n_2 \cdots n_k$ outcomes. (Made formal, “repeating this” is a proof by induction on the number of decisions.)

The hypothesis matters. Change the rules so that silver must go to a runner who comes later in the alphabet than the gold medalist.

A count where the product rule does not apply. If the silver medalist must come later in the alphabet than the gold medalist, the five gold medalists leave 4, 3, 2, 1 and 0 options. The branches have different sizes, so they must be added.
A count where the product rule does not apply. If the silver medalist must come later in the alphabet than the gold medalist, the five gold medalists leave 4, 3, 2, 1 and 0 options. The branches have different sizes, so they must be added.
Monocurl source
let gx = |a| -2.2 + a * 1.25
mesh tree = block {
    for (a in range(0, 5)) {
        . Seg([0.3, 1.85, 0], [gx(a), 1.1, 0], SLATE, 1.5)
        let kids = filter(range(0, 5), |x| x > a)
        for (j in range(0, len(kids))) {
            let x = gx(a) + (j - (len(kids) - 1) / 2) * 0.3
            . Seg([gx(a), 0.9, 0], [x, -0.1, 0], SLATE, 1.5)
            . Tile([x, -0.25, 0], kids[j], 0.26, 0.3, 0.72)
        }
        . Tile([gx(a), 1.0, 0], a, 0.4, 0.4, 0.85, 1)
        . center{[gx(a), -0.85, 0]} Math(to_string(len(kids)), 0.95, [INK, ROSE][len(kids) == 0])
    }
    . Pt([0.3, 1.85, 0], INK, 0.07)
    . center{[-3.2, 1.0, 0]} Note("gold", 0.74)
    . center{[-3.2, -0.85, 0]} Note("options", 0.74)
}
mesh total = center{[0.3, -1.65, 0]} Math("4 + 3 + 2 + 1 + 0 = 10 \qquad \text{not } 5 \times \text{anything}", 0.95, INK)

Uses the shared definitions for this lesson's figures.

Now gold for A leaves four options and gold for E leaves none. There is no single $n$, so there is nothing to multiply by, and the honest count is the sum $4 + 3 + 2 + 1 + 0 = 10$. Before multiplying, check that the number of options at a step is the same whatever came before.

Arrangements in order

The podium count generalizes directly, and the general objects have names.

A podium is a 3-permutation of the five runners, and a complete finishing order is a permutation of them.

For the runners, $P(5, 3) = 5 \cdot 4 \cdot 3 = 60$ and also $\frac{5!}{2!} = \frac{120}{2} = 60$. The whole field can finish in $5! = 120$ orders. Factorials grow quickly: $10! = 3{,}628{,}800$, and a deck of 52 cards has $52!$ orders, a number with 68 digits.

When order does not matter

Now the second question. A group of three qualifiers is a set, and the set $\{A, C, E\}$ is the same group as $\{E, A, C\}$. The product rule counts ordered things, so it cannot be applied to sets directly. Again start small, with groups of two.

Pause and try

There are 20 ordered outcomes for gold and silver. How many different pairs of medalists are there, if we no longer care which of the two got gold? In the array of 20, how often does the pair B and D occur?

Show answerHide answer

The pair occurs twice, as (B, D) and as (D, B). The same is true of every pair, so the 20 ordered outcomes consist of 10 pairs, each listed twice.

Every way to give gold (rows) and silver (columns) to five runners. The diagonal is impossible, since nobody wins both. Each cell in the shaded upper triangle has a mirror image below the diagonal with the same two runners, so the 20 ordered outcomes contain 10 different pairs.
Every way to give gold (rows) and silver (columns) to five runners. The diagonal is impossible, since nobody wins both. Each cell in the shaded upper triangle has a mirror image below the diagonal with the same two runners, so the 20 ordered outcomes contain 10 different pairs.
Monocurl source
let gy = |i| 1.12 - i * 0.64
let gxx = |j| -2.6 + j * 0.64
mesh cells = block {
    for (i in range(0, 5)) {
        for (j in range(0, 5)) {
            let p = [gxx(j), gy(i), 0]
            if (i == j) {
                . Box(p, [0.6, 0.6], ROSE, 0.1, 1.5)
                . Seg([p[0] - 0.17, p[1] - 0.17, 0], [p[0] + 0.17, p[1] + 0.17, 0], ROSE, 3)
                . Seg([p[0] - 0.17, p[1] + 0.17, 0], [p[0] + 0.17, p[1] - 0.17, 0], ROSE, 3)
            } else {
                . Box(p, [0.6, 0.6], SLATE, [0, 0.2][i < j], 1.5)
                . Card(p, [i, j], 0.25, 0.3, 0.7)
            }
        }
    }
}
mesh heads = [
    map(range(0, 5), |j| Tile([gxx(j), 1.76, 0], j, 0.34, 0.34, 0.75, 1)),
    map(range(0, 5), |i| Tile([-3.3, gy(i), 0], i, 0.34, 0.34, 0.75, 1)),
    center{[gxx(5) + 0.15, 1.76, 0]} Note("silver", 0.74),
    center{[-3.3, -1.86, 0]} Note("gold", 0.74)
]
mesh mirror = [
    Outline([[gxx(3) - 0.3, gy(1) - 0.3, 0], [gxx(3) + 0.3, gy(1) - 0.3, 0], [gxx(3) + 0.3, gy(1) + 0.3, 0], [gxx(3) - 0.3, gy(1) + 0.3, 0]], INK, 4),
    Outline([[gxx(1) - 0.3, gy(3) - 0.3, 0], [gxx(1) + 0.3, gy(3) - 0.3, 0], [gxx(1) + 0.3, gy(3) + 0.3, 0], [gxx(1) - 0.3, gy(3) + 0.3, 0]], INK, 4)
]
mesh panel = [
    center{[2.25, 1.2, 0]} Math("25 \text{ cells}", 0.85, INK),
    center{[2.25, 0.65, 0]} Math("-\ 5 \text{ on the diagonal}", 0.85, ROSE),
    center{[2.25, 0.1, 0]} Math("= 20 \text{ ordered}", 0.85, INK),
    center{[2.25, -0.75, 0]} Math("20 \div 2 = 10 \text{ pairs}", 0.95, LEAF),
    center{[2.25, -1.4, 0]} Note("outlined: B, D twice", 0.72)
]

Uses the shared definitions for this lesson's figures.

Dividing by 2 was legitimate for one reason: every pair appears the same number of times. For three qualifiers the same question has to be asked of the 60 podiums.

Pause and try

How many of the 60 podiums consist of the runners A, C and E in some order? Would the count differ for B, D and E? Use your answers to find the number of groups of three.

Show answerHide answer

Ordering A, C, E is itself a podium problem with three runners: $3 \cdot 2 \cdot 1 = 6$ orders. Nothing in that count depends on which three runners they are, so every group of three accounts for exactly 6 podiums, and there are $60 / 6 = 10$ groups.

  1. The group A, C, E appears among the 60 podiums six times, once for each order of its members.
  2. Any other group does the same. B, D, E can also be ordered in 3 × 2 × 1 = 6 ways.
  3. Every bundle has six podiums, so the number of groups is 60 / 6 = 10.
Forgetting the order sends six podiums to the same group of three. This holds for every group, so the 60 podiums fall into bundles of six, and the number of groups is 60 divided by 6.
Monocurl source
let orders = |t| [[t[0], t[1], t[2]], [t[0], t[2], t[1]], [t[1], t[0], t[2]], [t[1], t[2], t[0]], [t[2], t[0], t[1]], [t[2], t[1], t[0]]]
let Bundle = |cx, t| [
    map(range(0, 6), |i| Card([cx + (i // 3 - 0.5) * 1.4, 1.6 - (i - (i // 3) * 3) * 0.52, 0], orders(t)[i], 0.38, 0.4, 0.8)),
    Tip([cx - 0.5, 0.25, 0], [cx - 0.2, -0.3, 0], SLATE, 3, 0.17),
    Tip([cx + 0.5, 0.25, 0], [cx + 0.2, -0.3, 0], SLATE, 3, 0.17),
    Disc([cx, -1.0, 0], 0.66, SLATE, 0.12, 2.5),
    Card([cx, -1.0, 0], t, 0.34, 0.36, 0.8),
    center{[cx, -1.9, 0]} Note("one group", 0.8)
]
mesh left = []
mesh right = []
mesh answer = []

slide "The group A, C, E appears among the 60 podiums six times, once for each order of its members."
    left = Bundle(-2.1, [0, 2, 4])
    play Fade(0.7)

slide "Any other group does the same. B, D, E can also be ordered in 3 × 2 × 1 = 6 ways."
    right = Bundle(2.1, [1, 3, 4])
    play Fade(0.7)

slide "Every bundle has six podiums, so the number of groups is 60 / 6 = 10."
    answer = [
        center{[0, 0.2, 0]} Note("6 to 1", 0.8),
        center{[0, -0.95, 0]} Math("\frac{60}{6} = 10", 1.15, LEAF)
    ]
    play Fade(0.6, [&answer])

Uses the shared definitions for this lesson's figures.

This is what the animation at the top of the page carries out for all ten groups at once. Here is the general statement.

The step that carries the weight is “exactly $k!$ for every $T$”. If the groups had different sizes, division would give nonsense, as the product rule did when the branches were uneven.

One identity, two proofs

Pause and try

Compute $\binom{5}{2}$ and $\binom{5}{3}$ from the formula. Then explain the result without any formula.

Show answerHide answer

$\binom{5}{2} = \frac{5 \cdot 4}{2} = 10$ and $\binom{5}{3} = \frac{5 \cdot 4 \cdot 3}{6} = 10$. Choosing the three runners who qualify is the same decision as choosing the two who do not.

The ten groups of three runners. In each row the colored tiles are the three who qualify and the gray tiles are the two who do not. Read by its colored tiles the picture lists every 3-combination; read by its gray tiles it lists every 2-combination.
The ten groups of three runners. In each row the colored tiles are the three who qualify and the gray tiles are the two who do not. Read by its colored tiles the picture lists every 3-combination; read by its gray tiles it lists every 2-combination.
Monocurl source
let Row = |pos, t| map(range(0, 5), |x| [
    Ghost([pos[0] + (x - 2) * 0.5, pos[1], 0], x, 0.44, 0.44, 0.85),
    Tile([pos[0] + (x - 2) * 0.5, pos[1], 0], x, 0.44, 0.44, 0.85)
][x in t])
mesh rows = map(range(0, 10), |i| Row([[-1.95, 1.95][i // 5], 1.2 - (i - (i // 5) * 5) * 0.56, 0], COMMITTEES[i]))
mesh heads = [
    center{[-1.95, 1.85, 0]} Cap("colored: the 3 who qualify", 0.75, INK),
    center{[1.95, 1.85, 0]} Cap("gray: the 2 who do not", 0.75, SLATE),
    center{[0, -1.8, 0]} Math("\binom{5}{3} = \binom{5}{2} = 10", 0.85, LEAF)
]

Uses the shared definitions for this lesson's figures.

Both proofs are complete, and they do different jobs. The algebra confirms the identity and gives no reason for it. The counting argument never mentions a factorial: it shows the two numbers count the same decisions. An argument of this kind, which proves an equation by counting one collection in two ways or by matching two collections, is called a combinatorial proof.

Here is a second identity, where the counting argument also suggests the statement. Suppose the three qualifiers must name one of themselves captain. We can pick the group and then its captain, in $10 \times 3$ ways. Or we can pick the captain from all five runners and then the two who join them from the remaining four, in $5 \times \binom{4}{2} = 5 \times 6$ ways.

The 30 ways to pick three qualifiers and name one of them captain (solid tile). Arranged by group there are 10 stacks of 3. The same 30 cards are then rearranged by captain into 5 columns of 6.
Monocurl source
let cx = |c| (c - 2) * 1.4
var ends = []
var seen = [0, 0, 0, 0, 0]
for (i in range(0, 30)) {
    let t = COMMITTEES[i // 3]
    let cap = t[i - (i // 3) * 3]
    ends .= [cx(cap), 1.3 - seen[cap] * 0.38, 0]
    seen[cap] = seen[cap] + 1
}
let END = ends
let START = map(range(0, 30), |i| {
    let g = i // 3
    let band = g // 5
    return [cx(g - band * 5), 1.4 - (band * 3 + i - g * 3) * 0.38 - band * 0.2, 0]
})
let Cards = |t| map(range(0, 30), |i| Card(lerp(START[i], END[i], t), COMMITTEES[i // 3], 0.39, 0.34, 0.95, i - (i // 3) * 3))
mesh first = [
    center{[0, 1.9, 0]} Cap("group first, then its captain", 0.8, INK),
    center{[0, -1.3, 0]} Math("10 \times 3 = 30", 1.0, INK)
]
mesh cards = Cards(t: 0)
mesh second = []

slide "regroup"
    play Wait(1.5)
    first = []
    play Fade(0.4, [&first])
    cards.t = 1
    play Lerp(3, [&cards])
    second = [
        map(range(0, 5), |a| [
            Tile([cx(a), 1.84, 0], a, 0.36, 0.32, 0.8, 1),
            Path([[cx(a) - 0.6, 1.5, 0], [cx(a) - 0.6, 1.58, 0], [cx(a) + 0.6, 1.58, 0], [cx(a) + 0.6, 1.5, 0]], SLATE, 2)
        ]),
        center{[0, -1.08, 0]} Math("10 \times 3 = 30", 1.0, INK),
        center{[0, -1.5, 0]} Cap("captain first, then two more from the other four", 0.8, INK),
        center{[0, -1.92, 0]} Math("5 \times 6 = 30", 1.0, LEAF)
    ]
    play Fade(0.6, [&second])
    play Wait(2.2)

Uses the shared definitions for this lesson's figures.

Nothing here is special to 5 and 3.

Worked examples

Where the formulas stop

Each formula answers one kind of question, and neighboring questions have different answers.

Repetition allowed. If a runner could win more than one medal, each of the three medals would have 5 options regardless of the others, and the product rule would give $5^3 = 125$. In general there are $n^k$ ordered lists of length $k$ from $n$ objects when repeats are allowed. The formula $P(n, k)$ is for lists without repeats.

The ends of the range. With $k = 0$ there is one list, the empty one, and one subset, the empty set, so $P(n, 0) = \binom{n}{0} = 1$. The factorial formula agrees only because $0!$ was defined as 1, and that is the reason for the definition. With $k > n$ there are no lists without repeats and no subsets. The product $n(n-1)\cdots(n-k+1)$ then contains the factor $0$, while the form $\frac{n!}{(n-k)!}$ is meaningless there, which is why the theorems assume $k \le n$.

Objects that are not distinct. The word LEVEL has 5 letters but fewer than $5!$ arrangements, because swapping its two L’s changes nothing. Problem 6 handles it with the same division idea.

Stepping back

Two ideas did all the work. The product rule counts ordered outcomes built by a sequence of decisions, provided the number of options at each decision does not depend on the earlier ones. The division step converts an ordered count into an unordered one, provided every unordered object was counted the same number of times. Both provisos are the place to look when a count comes out wrong.

The numbers $\binom{n}{k}$ satisfy many identities, and the two-way counting used here is the standard way to find and prove them. Arranged in a triangle, they obey a simple addition rule, which is the subject of the lesson on Pascal’s triangle.

Check yourself

A class of 10 students elects a president and a vice-president (different people). How many outcomes are possible?

Problems

The first three use the formulas directly. The next four need a choice of method or an explanation. The last two extend the lesson.

Problem 1

Seven different books are on a desk. (a) In how many ways can three of them be lined up on a shelf? (b) In how many ways can three of them be chosen to take on a trip?

Show solutionHide solution

(a) The shelf has an order, so this is $P(7, 3) = 7 \cdot 6 \cdot 5 = 210$. (b) A choice is a set, and each set of three books was counted $3! = 6$ times in (a), so the answer is $\binom{7}{3} = 210 / 6 = 35$.

Problem 2

Ten people meet, and every two of them shake hands once. How many handshakes take place?

Show solutionHide solution

A handshake is a set of two people, so the count is $\binom{10}{2} = \frac{10 \cdot 9}{2} = 45$. The product $10 \cdot 9 = 90$ counts each handshake twice, once from each side.

Problem 3

A PIN is a list of four digits, each from 0 to 9. How many PINs are there, and what fraction of them have four different digits?

Show solutionHide solution

Each digit has 10 options regardless of the others, so there are $10^4 = 10{,}000$ PINs. With four different digits the options are 10, 9, 8, 7 in turn: $P(10, 4) = 5040$. The fraction is $\frac{5040}{10000} = 0.504$, so just over half of all PINs have no repeated digit.

Problem 4

Compute $\binom{100}{98}$ without a calculator, and explain in terms of choosing why $\binom{n}{1} = \binom{n}{n-1} = n$.

Show solutionHide solution

By symmetry $\binom{100}{98} = \binom{100}{2} = \frac{100 \cdot 99}{2} = 4950$. Choosing one object from $n$ can be done in $n$ ways, one for each object. Choosing $n - 1$ objects is the same as choosing the single object to leave out, which can again be done in $n$ ways.

Problem 5

A committee of 4 is to be formed from 6 men and 5 women. (a) How many committees have exactly two women? (b) How many have at least one woman?

Show solutionHide solution

(a) Choose the two women in $\binom{5}{2} = 10$ ways and, whichever they are, the two men in $\binom{6}{2} = 15$ ways. The product rule applies because the number of ways to choose the men does not depend on the women chosen, and each committee arises from exactly one such pair of choices: $10 \cdot 15 = 150$. (b) There are $\binom{11}{4} = \frac{11 \cdot 10 \cdot 9 \cdot 8}{24} = 330$ committees and $\binom{6}{4} = 15$ with no woman, so $330 - 15 = 315$ have at least one. Check by cases: $5 \cdot 20 + 10 \cdot 15 + 10 \cdot 6 + 5 = 100 + 150 + 60 + 5 = 315$.

Problem 6

How many different arrangements are there of the letters of the word LEVEL? Justify the division you use.

Show solutionHide solution

Make the letters temporarily distinct: $L_1, E_1, V, E_2, L_2$. These five distinct symbols have $5! = 120$ arrangements. Erasing the subscripts sends each of these to an arrangement of LEVEL. A given arrangement of LEVEL comes from exactly $2! \cdot 2! = 4$ labeled arrangements, since the two L’s can be labeled in 2 ways and, independently, the two E’s in 2 ways. Every bundle has the same size 4, so the number of arrangements is $120 / 4 = 30$.

Problem 7

A student is asked how many 5-card hands from a standard 52-card deck contain at least one ace, and writes: “Choose an ace, 4 ways. Then choose any 4 of the other 51 cards, $\binom{51}{4} = 249{,}900$ ways. Answer: $999{,}600$.” Find the error and the correct count.

Show solutionHide solution

The method counts pairs (a marked ace, four other cards). A hand with two aces arises from two such pairs, since either ace could be the marked one, and a hand with three or four aces arises three or four times. So hands are not counted equally often and the total is too large. Correctly: there are $\binom{52}{5} = 2{,}598{,}960$ hands, and $\binom{48}{5} = 1{,}712{,}304$ of them avoid all four aces, so $2{,}598{,}960 - 1{,}712{,}304 = 886{,}656$ contain at least one ace.

Problem 8

Prove in two ways, by counting and by algebra, that for integers $0 \le m \le k \le n$,

$$ \binom{n}{k}\binom{k}{m} = \binom{n}{m}\binom{n-m}{k-m}. $$
Show solutionHide solution

By counting. From $n$ people, form a committee of $k$ and, inside it, a subcommittee of $m$. Choosing the committee first gives $\binom{n}{k}$ committees, each with exactly $\binom{k}{m}$ subcommittees: $\binom{n}{k}\binom{k}{m}$ outcomes. Choosing the subcommittee first gives $\binom{n}{m}$ subcommittees, each of which is completed to a committee by choosing the other $k - m$ members from the remaining $n - m$ people, in exactly $\binom{n-m}{k-m}$ ways. Each outcome (a committee together with a subcommittee) arises exactly once either way, so the two products are equal. With $m = 1$ this is the captain identity. By algebra.

$$ \binom{n}{k}\binom{k}{m} = \frac{n!}{k!\,(n-k)!} \cdot \frac{k!}{m!\,(k-m)!} = \frac{n!}{m!\,(k-m)!\,(n-k)!}, $$
$$ \binom{n}{m}\binom{n-m}{k-m} = \frac{n!}{m!\,(n-m)!} \cdot \frac{(n-m)!}{(k-m)!\,(n-k)!} = \frac{n!}{m!\,(k-m)!\,(n-k)!}. $$

Numerical check with $n = 5$, $k = 3$, $m = 2$: $10 \cdot 3 = 30$ and $10 \cdot 3 = 30$.

Problem 9

Five people sit down at a round table with five identical chairs. Two seatings count as the same if one can be turned into the other by rotating everybody around the table. How many different seatings are there? Generalize to $n$ people.

Show solutionHide solution

Number the chairs. There are $5! = 120$ ways to seat the people in numbered chairs. Rotating everyone by one chair, two chairs, and so on gives 5 numbered seatings (including the original) that all count as the same round-table seating, and these 5 are different from one another because each rotation moves a given person to a different chair. So the 120 numbered seatings fall into bundles of exactly 5, and there are $120 / 5 = 24$ seatings. For $n$ people the same argument gives $n!/n = (n-1)!$. Another way to see it: seat one person anywhere, which fixes the rotation, and arrange the other $n - 1$ people in the remaining chairs in $(n-1)!$ ways.

Shared definitions used by this lesson's figures
# house kit: prepended to every essay figure after the std imports

# palette. AZURE and EMBER are the two actors, LEAF marks an answer, ROSE a problem
let PAPER = [1, 1, 1, 1]
let INK = [0.08, 0.09, 0.11, 1]
let SLATE = [0.40, 0.44, 0.50, 1]
let MIST = [0.85, 0.86, 0.88, 1]
let AZURE = [0.13, 0.42, 0.68, 1]
let EMBER = [0.89, 0.42, 0.12, 1]
let LEAF = [0.13, 0.55, 0.36, 1]
let ROSE = [0.78, 0.22, 0.24, 1]
let PLUM = [0.47, 0.30, 0.66, 1]
let GOLD = [0.85, 0.62, 0.08, 1]

background = PAPER

# an opaque pastel of col; use for fills so overlaps do not darken
let tint = |col, amount = 0.18| [
    1 - (1 - col[0]) * amount,
    1 - (1 - col[1]) * amount,
    1 - (1 - col[2]) * amount,
    1
]

# text: Cap for labels, Note for quiet labels, Math for typeset maths
let Cap = |txt, size = 0.75, col = INK| color{col} Text(txt, size, "Charter")
let Note = |txt, size = 0.65| color{SLATE} Text(txt, size, "Charter")
let Math = |tex, size = 0.9, col = INK| color{col} Tex(tex, size)

# a paper rectangle to sit behind text that crosses lines
let Plate = |pos, size| center{pos} fill{PAPER} stroke{alpha{0} PAPER, 0} Rect(size)

# shapes with fill and stroke both set, so no stray black appears
let Pt = |pos, col = INK, r = 0.075| center{pos} fill{col} stroke{col, 1} Circle(r, 48)
let Ring = |pos, col = INK, r = 0.1, w = 3| center{pos} fill{PAPER} stroke{col, w} Circle(r, 48)
let Seg = |a, b, col = INK, w = 3| stroke{col, w} Line(a, b)
let Path = |pts, col = INK, w = 3| stroke{col, w} Polyline(pts)
let Region = |pts, col| fill{col} stroke{alpha{0} col, 0} Polygon(pts)
let Outline = |pts, col = INK, w = 3| fill{alpha{0} PAPER} stroke{col, w} Polygon(pts)
let Shape = |pts, col, amount = 0.18, w = 3| fill{tint(col, amount)} stroke{col, w} Polygon(pts)
let Disc = |pos, r, col, amount = 0.18, w = 3| center{pos} fill{tint(col, amount)} stroke{col, w} Circle(r, 96)
let Box = |pos, size, col, amount = 0.18, w = 3| center{pos} fill{tint(col, amount)} stroke{col, w} Rect(size)
# a line from a to b ending in a small solid arrowhead
let Tip = |a, b, col = INK, w = 3, head = 0.17| {
    let d = normalize([b[0] - a[0], b[1] - a[1], 0])
    let n = [-d[1], d[0], 0]
    let base = [b[0] - d[0] * head, b[1] - d[1] * head, 0]
    return [
        stroke{col, w} Line(a, base),
        fill{col} stroke{col, 1} Polygon([
            b,
            [base[0] + n[0] * head * 0.42, base[1] + n[1] * head * 0.42, 0],
            [base[0] - n[0] * head * 0.42, base[1] - n[1] * head * 0.42, 0]
        ])
    ]
}

# plots. a frame is [x0, x1, y0, y1, centre, width, height]: a data window and the scene box it fills
let Frame = |x0, x1, y0, y1, c = [0, 0, 0], w = 6.4, h = 3.6| [x0, x1, y0, y1, c, w, h]
let fx = |fr, x| fr[4][0] + (x - (fr[0] + fr[1]) / 2) * fr[5] / (fr[1] - fr[0])
let fy = |fr, y| fr[4][1] + (y - (fr[2] + fr[3]) / 2) * fr[6] / (fr[3] - fr[2])
let at = |fr, x, y| [fx(fr, x), fy(fr, y), 0]

# axes through the data origin (or the nearest edge of the window), with optional names
let Axes = |fr, x_name = "", y_name = "", col = SLATE| {
    let ox = clamp(fr[0], 0, fr[1])
    let oy = clamp(fr[2], 0, fr[3])
    var parts = [
        Tip(at(fr, fr[0], oy), [fx(fr, fr[1]) + 0.25, fy(fr, oy), 0], col, 2.5, 0.15),
        Tip(at(fr, ox, fr[2]), [fx(fr, ox), fy(fr, fr[3]) + 0.25, 0], col, 2.5, 0.15)
    ]
    if (x_name != "") {
        parts .= center{[fx(fr, fr[1]) + 0.5, fy(fr, oy), 0]} Math(x_name, 0.8, col)
    }
    if (y_name != "") {
        parts .= center{[fx(fr, ox), fy(fr, fr[3]) + 0.5, 0]} Math(y_name, 0.8, col)
    }
    return parts
}

# tick marks with numbers at the listed data values
let XTicks = |fr, xs, col = SLATE, places = 0| block {
    let oy = fy(fr, clamp(fr[2], 0, fr[3]))
    for (x in xs) {
        . Seg([fx(fr, x), oy - 0.07, 0], [fx(fr, x), oy + 0.07, 0], col, 2)
        . center{[fx(fr, x), oy - 0.33, 0]} Math(to_string(x, places), 0.72, col)
    }
}
let YTicks = |fr, ys, col = SLATE, places = 0| block {
    let ox = fx(fr, clamp(fr[0], 0, fr[1]))
    for (y in ys) {
        . Seg([ox - 0.07, fy(fr, y), 0], [ox + 0.07, fy(fr, y), 0], col, 2)
        . center{[ox - 0.36, fy(fr, y), 0]} Math(to_string(y, places), 0.72, col)
    }
}

# faint grid lines at the listed data values
let GridLines = |fr, xs, ys, col = MIST| block {
    for (x in xs) {
        . Seg(at(fr, x, fr[2]), at(fr, x, fr[3]), col, 1.5)
    }
    for (y in ys) {
        . Seg(at(fr, fr[0], y), at(fr, fr[1], y), col, 1.5)
    }
}

# the graph of f over [a, b], drawn in the frame. values are clamped to the window
let Graph = |fr, f, a, b, col = AZURE, w = 4, n = 160|
    stroke{col, w} Polyline(map(sample(a, b, n), |x| at(fr, x, clamp(fr[2], f(x), fr[3]))))

# the region between the graph of f and the x axis over [a, b]
let AreaUnder = |fr, f, a, b, col = AZURE, amount = 0.2, n = 80| {
    var pts = [at(fr, a, 0)]
    for (x in sample(a, b, n)) {
        pts .= at(fr, x, clamp(fr[2], f(x), fr[3]))
    }
    pts .= at(fr, b, 0)
    return fill{tint(col, amount)} stroke{alpha{0} col, 0} Polygon(pts)
}

let NAMES = ["A", "B", "C", "D", "E"]
let COLS = [AZURE, EMBER, LEAF, PLUM, GOLD]
# a tile carrying one runner's letter; strong tiles are filled solid
let Tile = |pos, i, w = 0.3, h = 0.3, size = 0.7, strong = 0| [
    Box(pos, [w, h], COLS[i], [0.22, 1][strong], 2),
    center{pos} Cap(NAMES[i], size, [COLS[i], PAPER][strong])
]
# a quiet tile for a runner who is left out
let Ghost = |pos, i, w = 0.3, h = 0.3, size = 0.7| [
    Box(pos, [w, h], MIST, 0.25, 1.5),
    center{pos} Cap(NAMES[i], size, MIST)
]
# a row of tiles centred at pos; chair is the slot drawn solid, or -1
let Card = |pos, ids, w = 0.3, h = 0.3, size = 0.7, chair = -1| map(range(0, len(ids)), |c|
    Tile([pos[0] + (c - (len(ids) - 1) / 2) * (w + 0.012), pos[1], 0], ids[c], w, h, size, c == chair)
)
# every ordered triple of different runners, in dictionary order
let PODIUMS = block {
    for (a in range(0, 5)) {
        for (b in range(0, 5)) {
            for (c in range(0, 5)) {
                if (a != b and a != c and b != c) {
                    . [a, b, c]
                }
            }
        }
    }
}
# every set of three runners, written in increasing order
let COMMITTEES = block {
    for (a in range(0, 5)) {
        for (b in range(a + 1, 5)) {
            for (c in range(b + 1, 5)) {
                . [a, b, c]
            }
        }
    }
}
let key = |p| 2 ^ p[0] + 2 ^ p[1] + 2 ^ p[2]
let committee_of = |p| {
    var found = 0
    for (i in range(0, len(COMMITTEES))) {
        if (key(COMMITTEES[i]) == key(p)) {
            found = i
        }
    }
    return found
}
let others = |used| filter(range(0, 5), |x| not (x in used))
let col_x = |c| -3.3075 + c * 0.735