Fundamental Counting: Permutations & Combinations

Study Sheet

Fundamental Counting: Permutations & Combinations

Competition counting & probability, Unit 1

Addition & Multiplication Principles

Concept
The two rules that power all of counting

Multiplication Principle (AND). If a task splits into a sequence of independent stages, and stage ii can be done in nin_i ways regardless of the earlier choices, then the whole task can be done in

n1⋅n2⋅n3⋯nkn_1 \cdot n_2 \cdot n_3 \cdots n_k

ways. Use it when you make choice 1 and choice 2 and …

Addition Principle (OR). If the outcomes split into disjoint cases (no outcome lands in two cases at once), add the counts of the cases:

∣A1∣+∣A2∣+⋯+∣Ak∣.|A_1| + |A_2| + \cdots + |A_k|.

Use it when an outcome comes from case 1 or case 2 or …

The multiplication principle counts sequences of independent choices; permutations count ordered arrangements (n!n!, or n!(n−k)!\tfrac{n!}{(n-k)!} for kk of nn); combinations count unordered selections, (nk)\binom nk. The one question that decides between them: does swapping two chosen items produce a different outcome?

Example
Worked example: license plates

A plate has 2 letters (AA–ZZ) followed by 3 digits (00–99). How many plates are possible?

Solution. Five independent stages: 26⋅26⋅10⋅10⋅10=676,00026 \cdot 26 \cdot 10 \cdot 10 \cdot 10 = 676{,}000. Now suppose the first symbol may be either a letter or a digit (so 26+10=3626+10=36 choices) while the rest stay as before: the count becomes 36⋅26⋅10336 \cdot 26 \cdot 10^3. The “either/or” at one stage is an addition inside a multiplication.

Example
Worked example: routes, AND inside OR
ABC2 roads3 roads2 direct roadsvia B: 2 × 3 = 6; direct: 2; total 8
Solid roads pass through BB (2×32 \times 3 of them); dashed roads skip it (22). The cases are disjoint, so add.

Two roads join town AA to town BB, three roads join BB to CC, and two more roads go straight from AA to CC. How many routes lead from AA to CC without revisiting a town?

Solution. Split by whether the route passes through BB. These two cases share no route, so their counts add. A route through BB is a road A→BA\to B and a road B→CB\to C: every one of the 22 first roads can be followed by every one of the 33 second roads, so there are 2⋅3=62\cdot 3 = 6 such routes. The direct routes number 22. Total: 6+2=86 + 2 = 8.

Side note
Where it goes wrong

Multiplying when the number of choices at a stage is not constant. Count the even two-digit numbers with distinct digits. "Units digit: 55 choices (0,2,4,6,80,2,4,6,8); tens digit: 88 choices (not 00, not the units digit)" gives 5⋅8=405\cdot 8 = 40. But when the units digit is 00, the tens digit has 99 choices, not 88. Split the cases: units digit 00 gives 99 numbers; units digit 2,4,62,4,6 or 88 gives 4⋅8=324\cdot 8 = 32. The true count is 9+32=419 + 32 = 41.

Example
Worked example: casework by a special digit

How many 3-digit numbers (100–999) contain at least one digit equal to 77?

Solution. Complementary counting is cleanest: total 3-digit numbers =900=900. Those with no 77: first digit has 88 choices (11–99 except 77), the other two have 99 each, giving 8⋅9⋅9=6488\cdot 9 \cdot 9 = 648. So the answer is 900−648=252900-648 = 252.

Tip

Pitfall. The multiplication principle requires the number of ways at each stage to be constant, not the specific choices. If choosing AA first changes how many options remain at stage 2 (versus choosing BB), you must split into cases and add.

Try it
Quick check

A boy owns 44 shirts and 33 pairs of pants. How many different shirt-and-pants outfits can he wear?

Work it on paper before revealing the answer.

Show the answer

Answer: Shirt-and-pants outfits. An outfit is built by making two independent choices: pick a shirt, then pick a pair of pants. The choice of shirt does not affect the choice of pants, so by the Multiplication Principle we multiply the number of options for each stage:

(shirts)×(pants)=4×3=12.(\text{shirts}) \times (\text{pants}) = 4 \times 3 = 12.

There are 12\boxed{12} different outfits.

Factorials & Permutations

Concept
Ordered arrangements

n!=n(n−1)(n−2)⋯2⋅1n! = n(n-1)(n-2)\cdots 2 \cdot 1 counts the orderings of nn distinct objects, with 0!=10! = 1.

A permutation of kk objects chosen from nn distinct objects (order matters, no repetition) is

P(n,k)=n!(n−k)!=n(n−1)⋯(n−k+1)⏟k falling factors.P(n,k) = \frac{n!}{(n-k)!} = \underbrace{n(n-1)\cdots(n-k+1)}_{k\text{ falling factors}}.

Read it as: fill kk ordered slots, with nn choices for the first, n−1n-1 for the next, and so on.

Why the factors fall by one: once the first slot is filled, that object is used up, so the second slot has one fewer candidate, whatever was chosen first. The number of choices at each stage is fixed even though the choices themselves change, which is exactly what the multiplication principle needs. Writing the product as n!(n−k)!\tfrac{n!}{(n-k)!} is bookkeeping: n!n! would keep filling slots all the way down to 11, and dividing by (n−k)!(n-k)! strikes off the n−kn-k factors for the slots we never fill.

Example
Worked example: podium finishes
8gold8 left×7silver7 left×6bronze6 left8 × 7 × 6 = 336
One slot per medal; each runner placed removes one candidate for the next slot.

In a race of 88 runners, how many ways can the gold, silver, and bronze medals be awarded (no ties)?

Solution. Order matters and there is no repetition, so

P(8,3)=8⋅7⋅6=336.P(8,3) = 8 \cdot 7 \cdot 6 = 336.
Example
Worked example: arrange with a restriction

How many ways can 55 distinct books be lined up on a shelf if the dictionary must be on one of the two ends?

Solution. Place the dictionary first: 22 end choices. Arrange the other 44 books in the remaining slots: 4!=244! = 24. Total 2⋅24=482 \cdot 24 = 48. Handle the restricted object first.

Side note
Where it goes wrong

Filling the easy slots first. For the shelf of 55 books with the dictionary on an end, someone arranges "any 44 books in the first four places" (5⋅4⋅3⋅25\cdot4\cdot3\cdot2) and then asks whether the dictionary is left for an end. Now the last step depends on the earlier ones: sometimes the dictionary was already used in the middle, and the count cannot be finished by multiplying. Place the restricted object first (22 ends), then the rest freely (4!4!): 4848.

Tip

Tip. P(n,n)=n!P(n,n) = n! because 0!=10!=1. When a problem says “arrange,” “order,” “line up,” or “rank,” you are almost always in permutation territory.

Try it
Quick check

In a race of 77 runners, how many different ways can the first four places be filled (no ties)?

Work it on paper before revealing the answer.

Show the answer

Answer: Four ordered slots, no repeats. First place: 77 choices; second: 66 (anyone but the winner); third: 55; fourth: 44. The number of choices at each stage does not depend on who was chosen, so

P(7,4)=7⋅6⋅5⋅4=840.P(7,4) = 7\cdot 6\cdot 5\cdot 4 = 840.

There are 840\boxed{840} ways.

Combinations

Concept
Unordered selections

A combination chooses kk objects from nn distinct objects when order does not matter:

(nk)=n!k! (n−k)!=P(n,k)k!.\binom{n}{k} = \frac{n!}{k!\,(n-k)!} = \frac{P(n,k)}{k!}.

Dividing by k!k! removes the k!k! orderings of each chosen set. Key identities:

(nk)=(nn−k),(n0)=(nn)=1,∑k=0n(nk)=2n.\binom{n}{k} = \binom{n}{n-k}, \qquad \binom{n}{0}=\binom{n}{n}=1, \qquad \sum_{k=0}^{n}\binom{n}{k} = 2^{n}.

Why divide by k!k!: count ordered selections first, which is easy (P(n,k)P(n,k)), then ask how many times each set was counted. A set of kk objects can be listed in k!k! orders, and each order was a different ordered selection, so every set is counted exactly k!k! times, no more and no fewer. Dividing an overcount by a factor that is the same for every object is legitimate; that uniformity is the whole argument.

Example
Worked example: watching the overcount
AABBCCDDABACADBABCBDCACBCDDADBDC12 ordered pairs6 shaded sets12 / 2! = 6
Each team appears twice, mirrored across the diagonal; the shaded half lists each once.

How many 22-person teams can be chosen from A,B,C,DA,B,C,D?

Solution. Ordered choices first: 44 ways to pick a first member, 33 for the second, 1212 ordered pairs. The pair ABAB and the pair BABA are the same team, and every team appears exactly twice, once above the diagonal of the grid and once below it. So there are 12/2=612/2 = 6 teams, which is (42)=4⋅32!\binom42 = \tfrac{4\cdot 3}{2!}.

Example
Worked example: forming a committee

From 1010 people, how many ways can we choose a committee of 44?

Solution. Order is irrelevant: (104)=10⋅9⋅8⋅74⋅3⋅2⋅1=210.\binom{10}{4} = \frac{10\cdot 9\cdot 8\cdot 7}{4\cdot 3\cdot 2\cdot 1} = 210.

Example
Worked example: choosing with two groups

A club has 66 freshmen and 55 seniors. How many 44-person committees have exactly 22 freshmen?

Solution. Choose 22 of 66 freshmen and 22 of 55 seniors: (62)(52)=15⋅10=150\binom{6}{2}\binom{5}{2} = 15\cdot 10 = 150. (Multiplication principle joins two independent choices.)

Side note
Where it goes wrong

Building an "at least one" committee by first securing the requirement. How many 33-person committees from 55 seniors and 44 juniors include at least one senior? "Pick a senior (55 ways), then any 22 of the other 88 ((82)=28\binom82 = 28)" gives 140140. The true count is (93)−(43)=84−4=80\binom93 - \binom43 = 84 - 4 = 80. A committee with two seniors was counted twice (once for each senior playing "the" senior), and one with three seniors three times: 80+40+2⋅10=14080 + 40 + 2\cdot 10 = 140 exactly reproduces the overcount, since (52)(41)=40\binom52\binom41 = 40 committees have two seniors and (53)=10\binom53 = 10 have three.

Tip

Pitfall. (nk)\binom{n}{k} counts sets, not sequences. If you ever find yourself later imposing an order on a chosen set, you probably wanted a permutation, or you must multiply by the number of orderings.

Try it
Quick check

A pizza shop offers 88 toppings. How many different 33-topping pizzas can be ordered (three different toppings)?

Work it on paper before revealing the answer.

Show the answer

Answer: A pizza is a set of toppings: mushrooms-olives-ham is the same pizza in any order. Ordered choices give 8⋅7⋅6=3368\cdot 7\cdot 6 = 336, and each pizza appears in 3!=63! = 6 orders, so

(83)=3366=56.\binom83 = \frac{336}{6} = 56.

There are 56\boxed{56} pizzas.

Permutations with Identical Objects

Concept
Arrangements when some items repeat

The number of distinct arrangements of nn objects, where there are n1n_1 identical objects of type 1, n2n_2 of type 2, …, nrn_r of type rr (with n1+⋯+nr=nn_1 + \cdots + n_r = n), is the multinomial coefficient

n!n1! n2!⋯nr!.\frac{n!}{n_1!\,n_2!\cdots n_r!}.

Each group of identical objects contributes a k!k! overcount that must be divided out.

Why divide: pretend the identical objects carry invisible tags (I1,I2,I3,I4I_1, I_2, I_3, I_4), so all nn objects are distinct and there are n!n! arrangements. Erasing the tags merges arrangements: every word you can see comes from exactly n1! n2!⋯nr!n_1!\,n_2!\cdots n_r! tagged arrangements, one for each way of shuffling the tags within each group. Every word is overcounted by the same factor, so dividing by it is exact.

Example
Worked example: the smallest case, drawn out
A₁A₂BA₂A₁BA₁BA₂A₂BA₁BA₁A₂BA₂A₁AABABABAA3! = 6 tagged6 / 2! = 3 words
Each visible word comes from 2!2! tagged arrangements: the two orders of A1,A2A_1, A_2.

How many different words can be made from the letters A,A,BA, A, B?

Solution. Tag the two AA's as A1,A2A_1, A_2: now the three letters are distinct and have 3!=63! = 6 arrangements. Erasing the tags sends two tagged arrangements to each visible word (A1A2BA_1A_2B and A2A1BA_2A_1B both become AABAAB), so there are 3!2!=3\tfrac{3!}{2!} = 3 words: AAB,ABA,BAAAAB, ABA, BAA.

Example
Worked example: rearranging a word

How many distinct arrangements of the letters in MISSISSIPPI are there?

Solution. There are 1111 letters: M×1, I×4, S×4, P×2M{\times}1,\ I{\times}4,\ S{\times}4,\ P{\times}2. So

11!1! 4! 4! 2!=39,916,8001⋅24⋅24⋅2=34,650.\frac{11!}{1!\,4!\,4!\,2!} = \frac{39{,}916{,}800}{1\cdot 24\cdot 24\cdot 2} = 34{,}650.
Example
Worked example: lattice paths
(0,0)(4,3)R R U R U U R
The path drawn is the word RRURUURRRURUUR; choosing where the three UUs go fixes the path.

How many shortest grid paths go from (0,0)(0,0) to (4,3)(4,3) moving only right (R) or up (U)?

Solution. Every path is a sequence of 44 R's and 33 U's, so we arrange 77 steps:

7!4! 3!=(73)=35.\frac{7!}{4!\,3!} = \binom{7}{3} = 35.

Lattice-path counting is really “permutations with identical objects” in disguise — a favorite contest trick.

Side note
Where it goes wrong

Dividing by the wrong factorials. BANANABANANA has 33 AA's and 22 NN's, so it has 6!3! 2!=60\tfrac{6!}{3!\,2!} = 60 arrangements. Dividing only by 3!3! gives 120120, which still counts the two orders of the NN's as different words. Every group of identical letters needs its own factorial in the denominator; a letter that appears once contributes 1!=11! = 1.

Tip

Tip. The multinomial coefficient collapses to (nk)\binom{n}{k} when there are only two types (a “kk of one kind, n−kn-k of the other” string). Choosing positions and arranging identical objects are the same act.

Try it
Quick check

How many different arrangements of the letters of LEVELLEVEL are there?

Work it on paper before revealing the answer.

Show the answer

Answer: LEVELLEVEL has 55 letters: LL twice, EE twice, VV once. Tagging the repeats makes 5!=1205! = 120 arrangements, and each visible word comes from 2!2! orders of the LL's times 2!2! orders of the EE's:

5!2! 2! 1!=1204=30.\frac{5!}{2!\,2!\,1!} = \frac{120}{4} = 30.

There are 30\boxed{30} arrangements.

Circular Permutations

Concept
Seating around a table

Arrangements around a circle count only relative position: rotating everyone one seat gives the same arrangement. Fixing one person to kill the nn rotations gives

circular arrangements of n distinct objects=(n−1)!.\text{circular arrangements of } n \text{ distinct objects} = (n-1)!.

If arrangements that are mirror images (reflections) are also considered identical — as with a bracelet or necklace of beads — divide by an additional 22:

(n−1)!2(n≥3).\frac{(n-1)!}{2}\quad (n \ge 3).

Why (n−1)!(n-1)!: read each round seating clockwise starting from each of its nn seats. That produces nn different rows, and every row of nn people arises from exactly one seating read from exactly one seat. So the n!n! rows are the seatings overcounted by exactly nn, giving n!n=(n−1)!\tfrac{n!}{n} = (n-1)!. Fixing one person's seat is the same argument said differently: it picks one of the nn readings of each seating.

Example
Worked example: round table

In how many ways can 66 people sit at a round table if only relative order matters?

Solution. (6−1)!=5!=120(6-1)! = 5! = 120.

Example
Worked example: four people, seen from four seats
ABCDABCDBCDABCDACDABCDABDABCDABCone seating, 4 readings: 4! / 4 = 3! = 6 seatings
Rotating the table changes where the reading starts, not who sits next to whom.

Four people A,B,C,DA, B, C, D sit at a round table. Why are there 3!=63! = 6 seatings rather than 4!=244! = 24?

Solution. A seating can be written as a row by reading clockwise from any seat. The seating drawn gives four rows, ABCDABCD, BCDABCDA, CDABCDAB, DABCDABC: one seating, four rows. Each of the 2424 rows belongs to exactly one seating, and each seating owns exactly 44 rows, so the number of seatings is 24/4=624/4 = 6.

Example
Worked example: keyed seating

55 couples sit around a round table so that partners are adjacent. How many seatings (rotations equivalent)?

Solution. Treat each couple as a block: arrange 55 blocks around the circle in (5−1)!=24(5-1)! = 24 ways, then order the two partners within each block: 25=322^5 = 32. Total 24⋅32=76824 \cdot 32 = 768.

Side note
Where it goes wrong

Dividing by 22 for a table. Six people around a table have 5!=1205! = 120 seatings. Halving to 6060 treats a seating and its mirror image as the same, but at a table they are different: in one, AA has BB on the left; in the mirror, BB is on AA's right. Divide by 22 only when the object can be turned over, like a bracelet.

Tip

Pitfall. Decide up front whether reflections count as the same. Seats fixed to the table (labeled chairs, a head of table, a clock face) make it linear again — use n!n!, not (n−1)!(n-1)!.

Try it
Quick check

Five people sit at a round table, and two of them, Ana and Ben, insist on sitting next to each other. How many seatings are there (rotations count as the same)?

Work it on paper before revealing the answer.

Show the answer

Answer: Glue Ana and Ben into one block. Now 44 units sit around the table: (4−1)!=6(4-1)! = 6 ways. Inside the block, Ana can be on Ben's left or right: 22 ways. Total 6⋅2=126\cdot 2 = \boxed{12}.

Order Matters vs. Order Doesn't (Choosing vs. Arranging)

Concept
The master decision

Before counting, ask: does swapping two chosen items produce a different outcome?

  • Yes ⇒\Rightarrow order matters ⇒\Rightarrow arrangement/permutation: P(n,k)=n!(n−k)!P(n,k)=\dfrac{n!}{(n-k)!}.
  • No ⇒\Rightarrow order irrelevant ⇒\Rightarrow selection/combination: (nk)=n!k!(n−k)!\dbinom{n}{k}=\dfrac{n!}{k!(n-k)!}.

The bridge between them: P(n,k)=(nk)⋅k!P(n,k) = \binom{n}{k}\cdot k!. First choose the set, then arrange it.

Example
Worked example: same numbers, different question

From 99 students:

  • How many ways to pick a 33-person study group?   (93)=84\binom{9}{3}=84 (order doesn't matter).
  • How many ways to pick a President, VP, and Treasurer?   P(9,3)=9⋅8⋅7=504P(9,3)=9\cdot 8\cdot 7 = 504 (distinct roles ⇒\Rightarrow order matters).

Notice 504=84⋅3!=84⋅6504 = 84 \cdot 3! = 84\cdot 6.

Tip

Tip. Titles, ranks, ordered slots, and positions signal “order matters.” Committees, teams, hands of cards, and subsets signal “order doesn't.”

Try it
Quick check

From 77 candidates, (a) how many ways can a captain and a co-captain be chosen, and (b) how many ways can two representatives be chosen?

Work it on paper before revealing the answer.

Show the answer

Answer: (a) The roles differ, so swapping the two people gives a different outcome: P(7,2)=7⋅6=42P(7,2) = 7\cdot 6 = 42. (b) Two representatives are an unordered pair; each pair was counted twice in (a), so (72)=42/2=21\binom72 = 42/2 = 21.   42 and 21\boxed{42 \text{ and } 21}

Going Deeper: Subtleties, Overcounting & Symmetry

Concept
Necklaces vs. circular arrangements

A circular arrangement treats only rotations as identical: (n−1)!(n-1)!. A necklace (or bracelet) treats rotations and reflections as identical: (n−1)!2\frac{(n-1)!}{2} for n≥3n\ge 3. Always confirm whether the object can be physically flipped over. A round-table seating cannot be flipped (people keep their left/right neighbors distinct), but a bracelet of beads can.

Example
Worked example: overcounting by symmetry
12345678
The triangle on points 1,4,61, 4, 6 is one set of three points, but 3!=63! = 6 ordered triples.

How many distinct triangles can be drawn using 88 points on a circle as vertices (no three collinear)?

Solution. A triangle is just an unordered choice of 33 vertices, so (83)=56\binom{8}{3}=56. If you had counted ordered triples 8⋅7⋅6=3368\cdot 7\cdot 6 = 336, you would be overcounting each triangle by its 3!=63! = 6 vertex orderings: 336/6=56336/6 = 56. Recognizing the hidden symmetry factor is the whole game.

Example
Worked example: division-into-groups trap

In how many ways can 66 distinct players be split into 33 unlabeled pairs?

Solution. If the pairs were labeled (Court 1, 2, 3), the count would be (62)(42)(22)=15⋅6⋅1=90\binom{6}{2}\binom{4}{2}\binom{2}{2} = 15\cdot 6\cdot 1 = 90. But the 3!3! orderings of the (identical-status) pairs are the same partition, so divide: 90/3!=1590/3! = 15. Dividing by the arrangements of interchangeable groups is the most common contest overcount.

Example
Worked example: complementary & inclusion–exclusion

How many 44-digit numbers (1000–9999) have at least one repeated digit?

Solution. Total =9000=9000. All-distinct: 9⋅9⋅8⋅7=45369\cdot 9\cdot 8\cdot 7 = 4536 (first digit 11–99, then any unused digit including 00). At least one repeat =9000−4536=4464=9000 - 4536 = 4464. When “at least one” appears, subtract the “none” case.

Tip

Big picture — recognizing when order matters. Every basic counting problem reduces to three questions, asked in order:

  • Are stages joined by AND (multiply) or OR (add)? Split disjoint cases; never let one outcome fall into two cases.
  • Within a stage, does order matter? Yes ⇒\Rightarrow permutation P(n,k)P(n,k); No ⇒\Rightarrow combination (nk)\binom{n}{k}; repeats among items ⇒\Rightarrow divide by each group's factorial.
  • Did symmetry make me overcount? Rotations (÷n\div n), reflections (÷2\div 2), and interchangeable groups (÷k!\div k!) each demand a division. When in doubt, count an easy way with order, then divide out exactly the symmetries you introduced.
Try it
Quick check

Nine points lie on a circle. How many quadrilaterals have all four vertices among these points?

Work it on paper before revealing the answer.

Show the answer

Answer: Points on a circle are in convex position, so any 44 of them are the vertices of exactly one quadrilateral (join them in circular order). Counting ordered choices, 9⋅8⋅7⋅6=30249\cdot8\cdot7\cdot6 = 3024, lists each quadrilateral once for each of its 4!=244! = 24 vertex orders, so the count is 302424=(94)=126\tfrac{3024}{24} = \binom94 = \boxed{126}.

The Bijection Principle

Concept
Count a hard set by matching it to an easy one

If there is a bijection (a one-to-one, onto pairing) between a finite set AA and a finite set BB, then ∣A∣=∣B∣|A| = |B|. So to count a difficult set AA, build a reversible dictionary that turns each object of AA into exactly one object of an easier-to-count set BB — and back again. The whole method is: define the map, check it is invertible, count BB.

The lattice-path count you already met is a bijection in disguise: paths ⟷\longleftrightarrow words in R's and U's. Most “clever” contest counts are really the discovery of the right bijection.

Example
Worked example: stars and bars via a bijection

How many ways can we write x1+x2+x3+x4=10x_1 + x_2 + x_3 + x_4 = 10 with each xix_i a nonnegative integer?

Solution. Encode a solution as a row of 1010 stars split into 44 groups by 33 bars, e.g.

⋆⋆⏟x1=2 ∣ ⋆⋆⋆⏟x2=3 ∣ ⏟x3=0 ∣ ⋆⋆⋆⋆⋆⏟x4=5.\underbrace{\star\star}_{x_1=2}\ \mid\ \underbrace{\star\star\star}_{x_2=3}\ \mid\ \underbrace{}_{x_3=0}\ \mid\ \underbrace{\star\star\star\star\star}_{x_4=5}.

Every solution gives exactly one such string of 1010 stars and 33 bars, and every string decodes to exactly one solution — a bijection. Counting the strings is a “permutations with identical objects” problem on 1313 symbols:

(10+33)=(133)=286.\binom{10+3}{3} = \binom{13}{3} = 286.

In general x1+⋯+xk=nx_1 + \cdots + x_k = n (nonnegatives) has (n+k−1k−1)\binom{n+k-1}{k-1} solutions.

Example
Worked example: subsets with no two consecutive elements
123456789101112123456789−1−2−3ab{2, 5, 7, 11} → {2, 4, 5, 8}
With k=4k = 4, subtract 0,1,2,30,1,2,3: gaps of at least 22 become gaps of at least 11, and adding back undoes it.

How many subsets of {1,2,…,12}\{1,2,\dots,12\} contain no two consecutive integers?

Solution. Suppose we pick kk elements a1<a2<⋯<aka_1 < a_2 < \cdots < a_k with each gap ai+1−ai≥2a_{i+1}-a_i \ge 2. Define bi=ai−(i−1)b_i = a_i - (i-1). This subtracts off the forced gaps, and the map {ai}↦{bi}\{a_i\}\mapsto\{b_i\} is a bijection onto the kk-element subsets of {1,2,…,12−(k−1)}={1,…,13−k}\{1,2,\dots,12-(k-1)\} = \{1,\dots,13-k\} with no restriction. Hence the count for each kk is (13−kk)\binom{13-k}{k}, and summing over all kk:

∑k≥0(13−kk)=(130)+(121)+(112)+(103)+(94)+(85)+(76)=1+12+55+120+126+56+7=377.\sum_{k\ge 0}\binom{13-k}{k} = \binom{13}{0}+\binom{12}{1}+\binom{11}{2}+\binom{10}{3}+\binom{9}{4}+\binom{8}{5}+\binom{7}{6} = 1+12+55+120+126+56+7 = 377.

(These are Fibonacci numbers — a bijection can expose hidden structure, not just a number.)

Tip

Tip. To trust a bijection, exhibit the inverse: describe how to recover the original object from its image. If you cannot decode uniquely, the map is not a bijection and ∣A∣=∣B∣|A|=|B| may fail. “Shift the indices” (bi=ai−(i−1)b_i = a_i - (i-1)) is the single most useful bijection trick for turning a spacing constraint into a free choice.

Try it
Quick check

How many 33-element subsets of {1,2,…,8}\{1, 2, \ldots, 8\} contain no two consecutive integers?

Work it on paper before revealing the answer.

Show the answer

Answer: Write the subset as a1<a2<a3a_1 < a_2 < a_3 and set bi=ai−(i−1)b_i = a_i - (i-1). The gaps ai+1−ai≥2a_{i+1} - a_i \ge 2 become bi+1−bi≥1b_{i+1} - b_i \ge 1, and b3=a3−2≤6b_3 = a_3 - 2 \le 6, so {b1,b2,b3}\{b_1,b_2,b_3\} is any 33-subset of {1,…,6}\{1,\ldots,6\}; adding back 0,1,20,1,2 recovers the original. The count is (63)=20\binom63 = \boxed{20}.

Counting Functions Between Finite Sets

Concept
Every function is an assignment; count the assignments

Let ∣X∣=n|X| = n (the domain) and ∣Y∣=m|Y| = m (the codomain). Think of each element of XX as choosing a target in YY.

  • All functions X→YX \to Y: each of the nn inputs picks any of mm outputs independently, giving @@BLOCK0@@
  • Injective (one-to-one) functions: distinct inputs need distinct outputs, so fill the nn inputs with a falling factorial of choices: @@BLOCK1@@ which is 00 when n>mn > m (pigeonhole: too many inputs to keep distinct).
  • Surjective (onto) functions: every output in YY must be hit at least once. There is no bare product formula; inclusion–exclusion (a later unit) gives @@BLOCK2@@
Example
Worked example: three formulas, one setup
1234abcXY
A surjection {1,2,3,4}→{a,b,c}\{1,2,3,4\}\to\{a,b,c\}: every output is hit, so exactly one output (aa here) is hit twice.

Let X={1,2,3,4}X = \{1,2,3,4\} and Y={a,b,c}Y = \{a,b,c\}, so n=4n=4, m=3m=3.

Solution.

  • All functions: 34=813^4 = 81.
  • Injective functions: impossible, since n=4>3=mn=4 > 3 = m; count =0=0.
  • Surjective functions: ∑j=03(−1)j(3j)(3−j)4=34−3⋅24+3⋅14−0=81−48+3=36.\displaystyle\sum_{j=0}^{3}(-1)^j\binom{3}{j}(3-j)^4 = 3^4 - 3\cdot 2^4 + 3\cdot 1^4 - 0 = 81 - 48 + 3 = 36.

Sanity check: a surjection from a 44-set onto a 33-set forces exactly one output to be used twice. Choose the doubled output (33 ways), choose which 22 of the 44 inputs share it ((42)=6\binom{4}{2}=6), then biject the remaining 22 inputs to the remaining 22 outputs (2!=22!=2): 3⋅6⋅2=363\cdot 6\cdot 2 = 36. ✓

Tip

Tip. “Number of functions” problems are pure multiplication-principle problems wearing a costume: the domain elements are the independent stages. Watch the direction — functions X→YX\to Y give mnm^n, not nmn^m. The base is the size of the codomain (the menu); the exponent is the size of the domain (the diners).

The Multinomial Coefficient as a Distribution

Concept
One coefficient, three readings

For nonnegative integers with k1+k2+⋯+kr=nk_1 + k_2 + \cdots + k_r = n, define

(nk1, k2, …, kr)=n!k1! k2!⋯kr!.\binom{n}{k_1,\,k_2,\,\dots,\,k_r} = \frac{n!}{k_1!\,k_2!\cdots k_r!}.

This single number counts three equivalent things:

  • Arrangements: distinct orderings of nn objects where kik_i are of type ii (the MISSISSIPPI idea).
  • Distributions: ways to deal nn distinct objects into rr distinct labeled boxes so box ii receives exactly kik_i objects.
  • Ordered set partitions: ways to split {1,…,n}\{1,\dots,n\} into an ordered list of blocks of sizes k1,…,krk_1,\dots,k_r.

It also names the coefficients in the Multinomial Theorem

(x1+x2+⋯+xr)n=∑k1+⋯+kr=n(nk1,…,kr) x1k1x2k2⋯xrkr.(x_1 + x_2 + \cdots + x_r)^{n} = \sum_{k_1+\cdots+k_r = n} \binom{n}{k_1,\dots,k_r}\, x_1^{k_1}x_2^{k_2}\cdots x_r^{k_r}.
Example
Worked example: a specific coefficient

Find the coefficient of x3y2z2x^{3}y^{2}z^{2} in the expansion of (x+y+z)7(x + y + z)^{7}.

Solution. Here n=7n=7 with exponents (k1,k2,k3)=(3,2,2)(k_1,k_2,k_3) = (3,2,2), which sum to 77:

(73,2,2)=7!3! 2! 2!=50406⋅2⋅2=210.\binom{7}{3,2,2} = \frac{7!}{3!\,2!\,2!} = \frac{5040}{6\cdot 2\cdot 2} = 210.
Example
Worked example: dealing cards into hands

In how many ways can a standard 5252-card deck be dealt into four labeled hands (North, East, South, West) of 1313 cards each?

Solution. This is a distribution of 5252 distinct objects into 44 labeled boxes of size 1313:

(5213, 13, 13, 13)=52!(13!)4.\binom{52}{13,\,13,\,13,\,13} = \frac{52!}{(13!)^{4}}.

If instead the four hands were unlabeled (just a partition into four piles of 1313, no seat names), we would divide by the 4!4! orderings of the interchangeable piles: 52!(13!)4 4!\dfrac{52!}{(13!)^{4}\,4!}.

Tip

Identity worth knowing. The multinomial factors through binomials:

(nk1,k2,…,kr)=(nk1)(n−k1k2)(n−k1−k2k3)⋯(krkr).\binom{n}{k_1,k_2,\dots,k_r} = \binom{n}{k_1}\binom{n-k_1}{k_2}\binom{n-k_1-k_2}{k_3}\cdots\binom{k_r}{k_r}.

This is just “fill box 11, then box 22 from what remains, …” — the multiplication principle. Summing all multinomials of order nn gives rnr^{n} (set x1=⋯=xr=1x_1=\cdots=x_r=1 in the theorem), matching the “each of nn objects picks one of rr boxes” count.

Orientation: The Twelvefold Way

Concept
Distributing balls into boxes — the master chart

Almost every elementary counting problem is “put nn balls into mm boxes.” The answer depends on two switches — are the balls distinguishable? are the boxes distinguishable? — and on any restriction (no limit / at most one per box / at least one per box). The resulting 2×2×32\times 2\times 3 grid is the classic Twelvefold Way. Reading it now shows how the tools of this unit fit together and previews later units.

n balls, m boxesany numberat most one eachat least one eachdistinct balls, distinct boxesmnm(m−1)⋯(m−n+1)m! S(n,m)identical balls, distinct boxes(n+m−1n)(mn)(n−1m−1)distinct balls, identical boxes∑j=1mS(n,j)[ n≤m ]S(n,m)identical balls, identical boxes∑j=1mpj(n)[ n≤m ]pm(n)\begin{array}{l|c|c|c} n \text{ balls},\ m \text{ boxes} & \text{any number} & \text{at most one each} & \text{at least one each}\\\hline \text{distinct balls, distinct boxes} & m^{n} & m(m-1)\cdots(m-n+1) & m!\,S(n,m)\\ \text{identical balls, distinct boxes} & \binom{n+m-1}{n} & \binom{m}{n} & \binom{n-1}{m-1}\\ \text{distinct balls, identical boxes} & \sum_{j=1}^{m} S(n,j) & [\,n\le m\,] & S(n,m)\\ \text{identical balls, identical boxes} & \sum_{j=1}^{m} p_j(n) & [\,n\le m\,] & p_m(n) \end{array}

Here S(n,k)S(n,k) is a Stirling number of the second kind (partitions of a set into kk nonempty blocks), pm(n)p_m(n) counts partitions of the integer nn into exactly mm positive parts, and [ ⋅ ][\,\cdot\,] is 11 if the condition holds and 00 otherwise.

Example
Worked example: reading four cells of the chart

Distribute balls into 33 boxes; compare the four “any” entries for small cases.

Solution.

  • Distinct balls, distinct boxes, n=4n=4: functions {1,2,3,4}→{\{1,2,3,4\}\to\{box1,_1,box2,_2,box3}_3\}, so 34=813^4 = 81.
  • Identical balls, distinct boxes, n=4n=4: stars and bars, (4+3−14)=(64)=15\binom{4+3-1}{4} = \binom{6}{4} = 15.
  • Distinct balls, identical boxes, n=4n=4 into at most 33 nonempty groups: S(4,1)+S(4,2)+S(4,3)=1+7+6=14S(4,1)+S(4,2)+S(4,3) = 1 + 7 + 6 = 14.
  • Identical balls, identical boxes, n=4n=4 into at most 33 parts: partitions of 44 with ≤3\le 3 parts: 4, 3+1, 2+2, 2+1+14,\ 3{+}1,\ 2{+}2,\ 2{+}1{+}1, so 44.

Same phrase, four genuinely different answers — the two “distinguishable?” switches are everything.

Tip

Big picture. The top row (distinct/distinct) is this unit's home turf: functions, falling factorials, and surjection counts. The second row (identical balls, distinct boxes) is the stars-and-bars world of the next unit. The bottom two rows introduce set partitions (S(n,k)S(n,k)) and integer partitions (p(n)p(n)), the subject of still later units. When a problem stumps you, first locate its cell: are the balls alike? are the boxes alike? is there a per-box constraint?

Why It Works

(nk)=n!k!(n−k)!\binom nk = \tfrac{n!}{k!(n-k)!}: arrange all nn items in a row (n!n! ways), take the first kk as the chosen set. Each chosen set arises from k! (n−k)!k!\,(n-k)! arrangements (reorder the chosen, reorder the rest), so the number of sets is n!n! divided by that. The symmetry (nk)=(nn−k)\binom nk = \binom n{n-k} is choosing which items to leave out; Pascal's rule classifies subsets by whether they contain a fixed element.

Tip
Reading a proof

Do not read a proof the way you read a rule. Cover the last line, ask what the previous line forces, and only then uncover it. If a step feels like magic, that is the step to work by hand with a concrete number.

Formulas, Proofs & Tips

Tip
Counting: arrangements and selections
P(n,r)=n!(n−r)!,(nr)=n!r! (n−r)!P(n,r)=\frac{n!}{(n-r)!},\qquad \binom{n}{r}=\frac{n!}{r!\,(n-r)!}

What it means. Permutations count ordered arrangements; combinations count unordered selections.

Example. P(5,2)=5!3!=20P(5,2)=\tfrac{5!}{3!}=20 and (52)=10\binom52=10.

Why it works. Filling rr ordered slots from nn items gives n(n−1)⋯(n−r+1)=n!(n−r)!n(n-1)\cdots(n-r+1)=\tfrac{n!}{(n-r)!} choices. If order does not matter, every group of rr has been counted r!r! times — once per arrangement — so divide by r!r!.

Tip. Ask "would swapping two picks give a different outcome?" Yes →\to permutation. No →\to combination.