Arrangements and selections are the structures counted most often, and the product rule reaches them only by rebuilding the same argument every time.
This lesson turns that argument into formulas. It starts from the two questions the previous lesson left open, how many orders ten runners can finish in and how many committees of three ten people can form, then goes further: words whose letters repeat, selections in which a kind may be taken more than once, and routes along a grid. Each needs the right set to count, reached by a bijection (a perfect pairing between two sets, which forces them to have the same size) to something the product rule already handles.
Arrangements
Ten runners cross the line. The winner is any of the ; whoever won, second place is any of the left; then for third, and so on down to . The product rule, which multiplies the number of options at each stage provided that number does not depend on earlier choices, gives finishing orders. The product is written , read " factorial", and an ordering of distinct objects is a permutation of them. The convention , one way to arrange nothing, keeps the formulas below true at their edges.
If only the podium matters, the product stops after three stages: ways to award gold, silver and bronze. In general an ordered selection of objects from , nothing reused, can be made in
ways, the second form being the full factorial with the orders of the unused objects divided away. The probability course derives this and the next formula the same way and applies them to poker hands and the birthday problem.
Selections
A committee of three is a set, not a sequence. The podium lists count Ana, Ben, Chloe and Chloe, Ben, Ana separately, while as a committee they are one. The fix is the division rule: if a map from one set onto another sends exactly elements to each element of the target, the target has as many elements. Send each ordered list of three people to the set of those three. Every committee is hit by exactly lists, one per ordering of its members, so there are committees.
The number of element subsets of an element set is written , read " choose ", and the same argument gives
The formula is symmetric in and , and a bijection explains why without algebra: sending each subset to its complement pairs the element subsets perfectly with the element ones.
The previous lesson paired the subsets of an element set with bit strings of length , a marking each chosen element. Under that pairing a element subset becomes a string with exactly ones, so bytes have exactly three bits set. This reading, as the number of ways to choose which of positions receive a given symbol, is the one the rest of the lesson uses over and over.
Words with repeated letters
How many strings can be made by rearranging MISSISSIPPI? The probability course pretends the letters are distinct, giving , then divides out the orders of the S's, the of the I's and the of the P's that the pretence counted separately, reaching .
A second derivation builds the word instead of correcting an overcount, and it is the one that generalises. An arrangement is fixed once we know which positions hold each letter. Of the positions, choose the for M in ways; of the left, the for the I's in ways; of the still free, the for the S's in ways; the last take the P's. The number of options at each stage does not depend on which positions were taken before, so the product rule gives . Written out in factorials, everything cancels except on top and below.
In general a word of length with copies of one letter, of another and so on up to has
arrangements, a multinomial coefficient. With only two kinds of letter it is itself: arranging ones and zeros is the bit string count again.
Example. How many distinct arrangements does BOOKKEEPER have?
Count the letters first, since everything rests on it: B once, O twice, K twice, E three times, P once and R once, all accounted for. Then
omitting the factors . Checking by positions: ways to place the E's, for the O's, for the K's, and for the three single letters, and .
Now you. How many distinct arrangements does ABRACADABRA have, and in how many do the five A's stand together?
Answer
A five times, B twice, R twice, C and D once each, eleven in all: arrangements. With the A's together, glue them into one block; the word becomes seven symbols, the block, B, B, R, R, C and D, with arrangements.
Selections with repetition
A domino is an unordered pair of spot counts from to , repetition allowed, since the double six is a tile. Pairs of different values number and doubles , so a full set has tiles, as a real set does. Splitting into cases works for pairs but soon becomes painful. Three identical dice show a multiset of size three from six values (a multiset being a collection where order does not matter but repetition is allowed), and the cases all different, two alike and all alike already need care. One idea handles every case at once.
Record a multiset of size from types as a row of stars and bars. The bars cut the row into compartments, one per type in a fixed order, and the stars in each compartment say how many of that type were taken. For three dice, becomes |**|||*|: nothing before the first bar, so no ; two stars, so two s; two empty compartments for and ; one star for the ; nothing for . Any row of stars and bars reads back as exactly one multiset, so this is a bijection, and the rows are counted by choosing which of the positions hold stars. The number of multisets of size from types is therefore
Three dice give distinguishable outcomes, and dominoes , agreeing with the case count. The method is called stars and bars, and its only difficulty is seeing that the thing to count is not the objects but the dividers between the types.
Equations and distributions
The same count wears two other disguises. A multiset of size from types is determined by how many of each type it holds, whole numbers , each at least , adding to . So has solutions in nonnegative integers. Handing identical objects to people is the same list of numbers again: ten identical sweets shared among four children, some perhaps getting none, can be shared in ways.
Lower bounds are handled by handing out the guaranteed part first. If each child must get at least one sweet, give each one, then share the remaining six freely: ways. As equations, turns a positive solution of into a nonnegative solution of and back, a bijection. In general has positive solutions.
Upper bounds are different. If no child may have more than four sweets, there is nothing to hand out first. One counts everything and removes the distributions where some child exceeds the limit, but several can exceed it at once, so the removed sets overlap. Correcting for that overlap is the job of inclusion and exclusion, in a later lesson.
Example. A bakery sells five kinds of doughnut. How many different boxes of a dozen are there, and how many contain at least one of each kind?
A box is a multiset of size from types, stars and bars: boxes. For at least one of each, place one of each kind first and choose the other freely: boxes, which the positive solution formula confirms as .
Now you. How many solutions does have in integers with every variable at least ?
Answer
Set and likewise for the others. Then with every variable at least , which has solutions.
Lattice paths
Most of Manhattan is a grid of streets and avenues, fixed by the Commissioners' Plan of 1811. A walker going blocks east and north, never doubling back, has many shortest routes. Model the grid as the points with integer coordinates and a route as a lattice path from to made of unit steps, each right, , or up, .
The thing to count is the sequence of steps. Every such path takes five s and three s in some order, so it is a word of length , and every such word traces exactly one path. Choosing which of the positions are gives routes, and in general there are lattice paths from to .
Conditions yield to the product and sum rules. A path from to through is a path to followed by an independent path onwards, so the counts of the two legs multiply. A path that must avoid a point is counted by complement: all paths, minus those through it. Some conditions are harder. The paths from to that never rise above the line cannot be split at one point, since the condition binds at every step; there are for and for , the Catalan numbers, which a later lesson counts with generating functions.
Example. How many lattice paths run from to , how many pass through , and how many avoid it?
All paths: . To there are paths, and from the walker needs right and up, paths. Through the point, ; avoiding it, .
Now you. How many lattice paths from to avoid the point ?
Answer
All paths: . Through : paths to it and, with right and up remaining, from it, so . Avoiding it: .
Choosing what to count
Selecting things from kinds now has four answers, set by two questions: does order matter, and may a kind repeat? Ordered with repetition, the product rule gives . Ordered without, . Unordered without, . Unordered with, . With and they are , , and , so choosing the wrong model is never a small error.
Most counting mistakes answer a different question from the one asked, and the question to settle first is whether swapping two objects produces a different outcome. Ten different sweets handed to four children is ten independent choices of recipient, ways, not the of identical sweets. Three dice rolled by three different people give sequences, while three identical dice rolled together show one of outcomes, and those outcomes are not equally likely: arises from sequences and from one. Stars and bars counts outcomes, not probabilities.
A reliable habit is to state the bijection in words, such as "a box of doughnuts is a row of stars and bars", and check it both ways before computing. When no single formula fits, split into cases that do not overlap and add, as the domino count did with its doubles.
Numbers that keep returning
The binomial coefficients have appeared in every section: as committees, bit strings, positions in a word, stars and bars, and routes. They also satisfy identities that look like accidents of algebra. Checking by expanding factorials takes a line of fractions and explains nothing, and looks just as mysterious.
The lattice paths hint that neither is an accident. Every path to arrives by a last step, from or from , and the two kinds do not overlap, so the count to each point is the sum of the counts to the two points behind it. Written in binomial coefficients, that sentence is the first identity. The next lesson makes it a method: count one set in two ways, set the answers equal, and the identity arrives with its reason attached.