Combinatorics
Combinatorics is the study of enumeration and arrangement.
Counting Principles
Sum Rule
Given two mutually exclusive events, where the first event can occur in distinct ways and the second event in distinct ways, the total number of occurrences () for either event is . This extends to mutually exclusive events:
Examples
- There is theme parks and water parks in the area, the number choices to attending one of them only would be
Product Rule
Given two independent sequential events (where neither affects the other's outcome), where the first event has outcomes and the second has outcomes, the total number of compound outcomes () is . This extends to independent sequential choices:
Examples
- 4-digit PIN with options per digit yields combinations
- A 16-input AND gate with binary inputs has possible input
- Restaurant offers appetizers, entrees, desserts. There are distinct meal combinations
Arrangements
Permutations
A permutation is an ordered arrangement of distinct objects. Since objects choice cannot be repeated, the number of choice decrease by one every time a object is chosen in a permutation, therefore the total permutation of distinct objects is given by the factorial function:
When selecting number of objects from distinct objects, the number of choice for each selection therefore decreases by one similarly, but only down to the last position needed, therefore the permutation is:
Examples
- Number of ways you can put people in a queue from a class of people,
- runners distributed across gold/silver/bronze positions: arrangements
- 7 teams assigned to 7 distinct time slots: distinct schedules
Combinations
A combination is a selection of objects from distinct objects where order is irrelevant. Since the number of ways to permute the given selection is (), the combination () can multiply to obtain the permutation ():
Examples
- Number of ways you can put people in a group from a class of people,
- 5 members chosen from 20 candidates:
Arrangements of Non-Distinct Objects
Given a objects with types (type has quantity where ), the total permutation () according to the size of the finite set can be over the unique arrangements. Since the permutation () of objects in repetitive position gives the number of arrangements that leaves the arrangement of the whole trial unchanged, the distinct permutations () are given by the multinomial coefficient.
Examples
- Arranging "TRIGGER" (7 letters: T,R,I,G,G,E,R):
, , , others unique distinct sequences.
Non-negative Integer solutions
In a case where , , the possible number of solutions () can be thought of using the stars and bars method. This method imagine a number of bars as separations between each share of distributed to each , due to the discrete behavior of the separations, can be thought of as a number of stars. The total state the three bars are allowed in is therefore , therefore the possible number of solutions would be the combination of the bars, hence:
Examples
-
- There are stars : , bars to separate
- One possible state would be : , equal to
Inclusion-Exclusion Principle
Two Sets
For finite sets and :
Proof
Every element of is either in exactly one of or in both. Summing counts elements in twice, so subtract one copy:
Three Sets
Proof
Apply the two-set formula iteratively:
General Formula
For finite sets :
The sign alternates: add singleton sizes, subtract pairwise intersections, add triple intersections, and so on.
Connection to Probability The inclusion-exclusion principle has a direct analogue in probability via the addition rule). If are events in a sample space , then:
This is just inclusion-exclusion divided by .
Examples
Example 1. In a class of 40 students, 25 study Physics, 20 study Chemistry, and 12 study both. How many study at least one of the two subjects?
Example 2. A survey of 100 households: 60 have broadband, 50 have cable TV, 30 have streaming, 20 have broadband and cable, 15 have broadband and streaming, 10 have cable and streaming, and 5 have all three. How many have at least one service?
All 100 households have at least one service.
Example 3. How many integers in are divisible by 2, 3, or 5?
Let be the sets of integers divisible by 2, 3, 5 respectively:
Circular Permutations
Standard Result
The number of distinct arrangements of distinct objects around a circle is .
Proof
In a linear arrangement, objects yield permutations. In a circle, rotating the entire arrangement does not produce a new configuration. There are distinct rotations of any arrangement (rotate by positions), so:
Equivalently: fix one object in a reference position to break rotational symmetry, then arrange the remaining objects linearly in ways.
Directional Equivalence
If clockwise and anticlockwise arrangements are considered the same (e.g. necklaces, key rings), each arrangement is counted twice in (once for each direction). The corrected count is:
Only apply the division by 2 when the problem explicitly states that reflections are equivalent. For problems involving people seated at a round table, clockwise and anticlockwise orderings are distinct -- a seating where person has person on their left is different from person on their right.
Examples
Example 1. How many ways can 6 people sit around a circular table?
Fix one person, arrange the remaining 5: .
Example 2. How many ways can 5 distinct beads be arranged on a bracelet (reflections equivalent)?
Example 3. 4 couples (8 people) sit at a round table. How many arrangements if each couple sits together?
Treat each couple as a block: 4 blocks in a circle gives arrangements. Each block has internal arrangements. Total:
Derangements
Definition
A derangement of objects is a permutation with no fixed points -- no object occupies its original position. The number of derangements of objects is denoted (the subfactorial of ).
Formula via Inclusion-Exclusion
Let be the set of permutations where element is in its original position. We want where is the set of all permutations:
Derivation
There are ways to choose specific elements to be fixed, and ways to permute the remaining elements. Inclusion-exclusion gives:
Recursive Formula
with and .
Proof
Consider element 1. In any derangement, element 1 is sent to some position (there are choices for ). Now consider element :
- If element goes to position 1, the remaining elements must be deranged among themselves: ways.
- If element does not go to position 1, we have elements (all except 1) with positions (all except position ), where element cannot go to position 1 and each remaining element cannot go to its own position: ways.
Since can be any of elements:
Small Values
| 0 | 1 | 2 | 3 | 4 | 5 | 6 | |
|---|---|---|---|---|---|---|---|
| 1 | 0 | 1 | 2 | 9 | 44 | 265 |
Examples
Example 1 (Hat-Check Problem). 5 guests check their hats. The attendant returns them at random. What is the probability that nobody gets their own hat?
Total permutations: . Derangements: .
Example 2 (Letter-Stuffing Problem). A secretary types 4 letters and 4 addressed envelopes, then stuffs them randomly. What is the probability that exactly one letter goes to the correct envelope?
First, choose which letter is correct: ways. The remaining 3 letters must all be in wrong envelopes: ways. Total:
Combinations with Restrictions
Complementary Counting
When a problem asks for "at least" or "at most" conditions, it is often easier to count the complement and subtract from the total.
Inclusion/Exclusion of Items
When certain items must be included, pre-select them and choose the rest from the remaining pool. When items must be excluded, remove them from the pool before choosing.
Partitioning into Groups
When dividing distinct objects into unlabeled groups of sizes (where ):
If some groups have equal size and are unlabeled, divide by the factorial of the number of identical groups to avoid overcounting.
Examples
Example 1. From 12 people, choose a committee of at least 3 and at most 5.
Example 2. A committee of 5 is chosen from 8 men and 6 women. It must include at least 2 women.
Total: . Subtract committees with 0 or 1 woman:
Example 3. Divide 10 distinct students into two unlabeled groups of 5.
The division by is necessary because the two groups are indistinguishable -- choosing and is the same partition as choosing and .
Common Pitfalls
Permutations vs Combinations
Order matters in permutations, not in combinations. Ask: does swapping two selected elements produce a different outcome?
- Arranging books on a shelf: permutation (order matters).
- Choosing a committee: combination (order does not matter).
- Assigning gold/silver/bronze: permutation. Selecting 3 finalists: combination.
The relationship is the definitive test -- if you can justify dividing out the , you have a combination.
Double-Counting in Inclusion-Exclusion
When applying inclusion-exclusion, every correction must be applied with the correct sign. A common error is forgetting to add back the triple intersection after subtracting pairwise intersections. The sign pattern is , , , , for intersections of size 1, 2, 3, 4, respectively. Always verify by checking a small case manually.
Forgetting Identical Objects
If objects are not all distinct, the formula overcounts. Always check whether any objects in the problem are identical (identical books, identical balls, repeated letters). Use the multinomial coefficient to correct for repetitions.
Off-by-One in Circular Permutations
The standard formula assumes rotational symmetry is the only equivalence. Do not divide by 2 unless the problem states that reflections are equivalent (necklace-type problems). For people seated around a table, is correct -- do not use .
Stars and Bars vs Direct Counting
Stars and bars counts the number of non-negative integer solutions to an equation. It does not apply when:
- Variables have upper bounds (e.g. each person gets at most 3 items) -- use inclusion-exclusion to subtract invalid cases.
- Objects are distinct -- use the multiplication principle or Stirling numbers instead.
- Order matters within groups -- stars and bars only counts compositions, not arrangements.
When in doubt, check whether the objects being distributed are identical and whether the recipients are distinct.
Wrap-up Questions
- Question: How many 8-character passwords exist if they must contain at least one uppercase letter, one lowercase letter, one digit, and one symbol (from 10 symbols), with no repeated characters?
Answer
- Total permutations of 8 distinct characters from 72 options (26 uppercase, 26 lowercase, 10 digits, 10 symbols): .
- Subtract invalid cases using inclusion-exclusion (approximate): Note: since the character types have different sizes (26, 26, 10, 10), the inclusion-exclusion terms subtract cases missing one type, add back cases missing two types, etc., using the size of the remaining pool after removing each type.
- Question: You have 9 books: 4 distinct mathematics books, 3 identical physics books, and 2 identical chemistry books. How many distinct ways can they be arranged on a shelf?
Answer
- Account for identical books: .
- Question: From 10 people, select a committee of 5 with roles: president, vice-president, and 3 indistinct members. How many ways can this be done?
Answer
- Choose president and vice-president (ordered): .
- Choose 3 indistinct members from remaining: .
- Total: .
- Question: 6 people queue for a bus, but 2 refuse to stand next to each other. How many valid permutations exist?
Answer
- Total permutations: .
- Subtract permutations where the two are adjacent: .
- Valid: .
- Question: An exam has sections with questions each. How many ways can you choose questions if you must pick from each section?
Answer
- Use inclusion-exclusion: (Note: , ).
- Question: Divide 10 students into two groups of 5, but Alice and Bob cannot be in the same group. How many unique arrangements can be made?
Answer
- Total ways to partition into unlabeled groups: .
- Subtract cases where Alice and Bob are together: (since fixes them together).
- Question: How many 4-letter words can be formed from "MISSISSIPPI" with no repeated letters?
Answer
- Only 4 distinct letters (M,I,S,P) in the multiset. Impossible to form words with no repeats: .
- Question: A pizza place offers 10 distinct toppings (6 meat, 4 vegetable). How many pizzas can be made with 3-5 toppings, including at least one meat and one vegetable?
Answer
- For toppings (): (exclude all-meat/all-vegetable).
- Sum: .
- Question: A student must choose 4 courses from 7 morning and 5 afternoon offerings, with 1 morning and 2 afternoon courses. How many ways?
Answer
- Cases: (1 morning, 3 afternoon) or (2 morning, 2 afternoon).
- .
- Question: A license plate has 3 distinct letters (A-Z) followed by 3 distinct digits (0-9). How many plates exist if the number formed by the digits is even?
Answer
- Letters: .
- Digits: Choose last digit (even: 0,2,4,6,8; 5 options), then arrange first two from remaining 9 digits: .
- Total: .
- Question: A bag has 6 identical red, 4 identical blue, and 5 identical green marbles. How many distinct ways can you draw 4 marbles?
Answer
- Nonnegative integer solutions to : .
- Question: How many 5-card poker hands contain at least one card from each suit?
Answer
- Choose suit with two cards: .
- Choose 2 cards from that suit: .
- Choose 1 card from each other suit: .
- Total: .
- Question: Arrange 5 distinct math and 4 distinct history books on a shelf such that no two math books are adjacent.
Answer
- Arrange history books (creates 5 gaps): .
- Place math books in gaps (one per gap): .
- Total: .
- Question: How many positive integers have digits summing to ?
Answer
- Represent numbers as 3-digit strings (allow leading zeros).
- Nonnegative solutions to with : (subtract cases where a digit 10).
- Question: A family (parents, two children) and 3 friends are seated in a row. Parents must sit together, and children must be separated by at least one adult. How many arrangements?
Answer
- Treat parents as a block: internal arrangements.
- Total with parents together: .
- Subtract cases where children are adjacent (treat as a block): .
- Valid: .
- Question: Assign 10 distinct gifts to 3 distinct children such that each gets 2 gifts.
Answer
- Total assignments: .
- Subtract cases where a child gets gifts (inclusion-exclusion):
- Question: Pair 5 men and 5 women for a dance. Two men (A,B) refuse to dance with a particular woman (X). How many valid pairings?
Answer
- Total pairings: .
- Subtract pairings where A or B is paired with X: .
- Question: How many distinct 4-digit numbers can be formed from
{1,2,3,4,5,6}with each digit used times?
Answer
- Case 1 (all distinct): .
- Case 2 (one digit twice, two once): .
- Case 3 (two digits twice): .
- Total: .
- Question: A coin is flipped 10 times. How many outcomes have between 3 and 5 heads (inclusive)?
Answer
- Sum: .
- Question: A bakery has 8 types of donuts. How many ways to buy a dozen (12) if you must buy of each type?
Answer
- First take one of each type. Distribute remaining 4 donuts freely: .
Diagnostic Test Ready to test your understanding of Combinatorics? The diagnostic test contains the hardest questions within the DSE specification for this topic, each with a full worked solution.
Unit tests probe edge cases and common misconceptions. Integration tests combine Combinatorics with other DSE mathematics topics to test synthesis under exam conditions.
See Diagnostic Guide for instructions on self-marking and building a personal test matrix.