Sub topic 7
Restrictions, 'at least' conditions, and the complement method
This chapter assumes you can compute permutations and combinations (P(n, r) and C(n, r)), apply the multiplication and addition principles, and simplify factorials. It also assumes you know how to count arrangements with identical items. Here you will learn to count when a problem adds a restriction, and to choose between counting directly and counting the opposite.
The complement idea
The complement method rests on one identity:
Count of what you want = Count of everything − Count of what you do not want.
"Everything" means all outcomes with no restriction. "What you do not want" means the outcomes that break the condition. The method pays off when the unwanted set is much easier to describe than the wanted set.
Counting directly often means splitting into many cases. Counting the complement often takes one multiplication or one combination.
"At least" conditions
The phrase "at least one" covers every case except "none." If a count has many cases (1, 2, 3, ...), the complement collapses them into one.
Take a committee of 3 chosen from 6 men and 4 women, with at least 1 woman.
Counting directly needs three cases: 1 woman, 2 women, or 3 women. Counting the complement needs one subtraction:
- All possible committees:
C(10, 3) = 120. - Committees with no women, so all men:
C(6, 3) = 20. - Committees with at least one woman:
120 − 20 = 100.
import math
# Committee of 3 from 6 men and 4 women, with at least 1 woman
total = math.comb(10, 3) # 120
no_women = math.comb(6, 3) # 20
print(total - no_women) # 100The direct method gives the same answer, which is a useful check:
- 1 woman:
C(4,1) × C(6,2) = 4 × 15 = 60 - 2 women:
C(4,2) × C(6,1) = 6 × 6 = 36 - 3 women:
C(4,3) × C(6,0) = 4 × 1 = 4 - Sum:
60 + 36 + 4 = 100
Both routes agree. The complement took two lines. The direct route took three products and a sum.
"At most" and "at least" are not symmetric
The complement of "at least k" is "fewer than k," which is "at most k − 1." The complement of "at most k" is "at least k + 1." Get the boundary right:
| Condition | Complement |
|---|---|
| At least 1 | None (0) |
| At least 2 | 0 or 1 |
| At most 2 | 3 or more |
| More than 2 | 0, 1, or 2 |
| Exactly 2 | Anything other than 2 |
An off-by-one error here is the most common mistake in this topic. Write the complement out in words before you compute it.
Restrictions on arrangements: "together" and "not together"
Arrangement problems add restrictions such as "two people must sit together" or "must not sit together." The complement method handles the second kind well.
Forcing items together: the block method
To make two items adjacent, glue them into a single block and treat the block as one object. Then count the orderings inside the block.
Five people sit in a row, and two specific people, call them Ana and Ben, must sit together.
- Treat Ana and Ben as one block. You now arrange 4 objects: the block and the 3 other people. That gives
4! = 24orderings. - Inside the block, Ana and Ben can appear as Ana-Ben or Ben-Ana. That gives
2! = 2orderings. - By the multiplication principle, the total is
24 × 2 = 48.
Keeping items apart: subtract
For "Ana and Ben must not sit together," count all arrangements and remove the ones where they are together:
5! − 48 = 120 − 48 = 72
import math
# 5 people in a row; two specific people must sit together
together = math.factorial(4) * math.factorial(2) # treat the pair as one block, then order the pair
print(together) # 48
print(math.factorial(5) - together) # 72 arrangements where they are NOT togetherCounting the "not together" case directly is possible but awkward. You would place the pair in non-adjacent seats and fill in everyone else, with several position cases. Subtraction avoids that.
Restrictions on positions: fill the restricted spot first
Some restrictions fix what can occupy a particular position, for example "the first digit cannot be 0" or "the driver must be a licensed adult." The rule is to fill the most restricted position first, then the rest.
How many 3-digit numbers can be formed from the digits 0 through 9 if digits may not repeat, and the first digit cannot be 0?
- First digit: 9 choices (1 through 9).
- Second digit: any of the 9 remaining digits, including 0. That gives 9 choices.
- Third digit: 8 choices.
The total is 9 × 9 × 8 = 648.
If you filled the positions left to right without thinking, you might multiply 10 × 9 × 8 = 720 and then forget the restriction. If you filled the third position first with any digit, you could not tell how many choices remain for the first digit, because it depends on whether 0 was already used. Handling the restricted position first keeps the choice counts independent.
The complement check works here as well. Without the restriction there are 10 × 9 × 8 = 720 strings. Those starting with 0 number 1 × 9 × 8 = 72. Then 720 − 72 = 648, which matches.
import math
total = math.perm(10, 3) # 720 three-digit strings, no repeats
starts_with_zero = math.perm(9, 2) # 72: fix 0 first, arrange 2 of the other 9
print(total - starts_with_zero) # 648Restrictions with a fixed condition on a selection
When a restriction names specific people or items, split the problem by whether the named item is in the selection.
A committee of 3 is chosen from 7 people, and two of them, Cho and Dev, refuse to serve together. Count the valid committees.
- All committees:
C(7, 3) = 35. - Committees containing both Cho and Dev: choose the third member from the other 5, so
C(5, 1) = 5. - Valid committees:
35 − 5 = 30.
The unwanted set is easy to describe because fixing both people leaves only one free choice. This is the pattern: the complement fixes the restricted items, which shrinks the problem.
Common errors
- Counting the complement of the wrong thing. The complement of "at least 2 women" is "0 or 1 women," not "0 women." Write the opposite in words first.
- Subtracting the wrong total. The "all outcomes" count must use the same rules as the unwanted count (same order convention, same repeat rule). If the wanted count is a combination, the total must be a combination too.
- Forgetting the internal order of a block. Gluing two people into a block gives
(n − 1)!orderings of the objects, and you must still multiply by2!for the order inside the block. A block of three items multiplies by3!. - Mixing direct and complement counts in one sum. Pick one approach for the whole problem. Adding a complement count to a direct case count double counts or drops outcomes.
- Ignoring overlaps between several unwanted conditions. If a problem has two separate bad conditions, the unwanted outcomes may overlap, and you need inclusion-exclusion to avoid subtracting the overlap twice. That tool is the subject of the Venn chapters later in this tutorial.
Worked example: combining techniques
A security code has 4 characters chosen from the 6 letters A, B, C, D, E, F, with no repeats. How many codes contain at least one of the letters A or B?
The condition is "at least one of A or B," so the complement is "contains neither A nor B."
- All codes:
P(6, 4) = 6 × 5 × 4 × 3 = 360. - Codes with neither A nor B use only C, D, E, F, so
P(4, 4) = 4! = 24. - Codes with at least one of A or B:
360 − 24 = 336.
import math
total = math.perm(6, 4) # 360
neither = math.perm(4, 4) # 24: only C, D, E, F are allowed
print(total - neither) # 336Counting directly would require cases for "A only," "B only," and "both," with positions chosen for each. The complement is one subtraction.
Choosing your method
| Situation | Preferred method |
|---|---|
| "At least one" of something | Complement: total minus none |
| "Not together" or "not adjacent" | Complement: total minus together |
| "Must be together" | Block method, then order inside the block |
| A position cannot hold certain values | Fill the restricted position first |
| Two people refuse to serve together | Total minus committees with both |
| Only one or two simple cases exist | Count directly |
If you are unsure, compute both ways when time allows. Matching answers are strong evidence that the setup is right.
Exercise
Six students sit in a row. Two of them, Mia and Noor, must NOT sit next to each other. How many seatings are possible?
Show answer
Total seatings: 6! = 720. Seatings with Mia and Noor adjacent: treat them as a block, so 5! orderings of the objects times 2! orderings inside the block = 120 × 2 = 240. Seatings where they are not adjacent: 720 − 240 = 480.
Exercise
A team of 4 is chosen from 5 engineers and 5 designers. How many teams contain at least 2 designers?
Show answer
Use the complement of "at least 2 designers," which is "0 or 1 designer." Total teams: C(10, 4) = 210. Teams with 0 designers: C(5, 4) = 5. Teams with 1 designer: C(5, 1) × C(5, 3) = 5 × 10 = 50. Unwanted total: 55. Answer: 210 − 55 = 155.