Lesson 23 of 42 · Counting, probability and statistics

Counting problems: restrictions, cases and the complement

Handle restricted positions, people who must sit together or apart, and "at least one" counts by cases or by the complement, checking one with the other.

About 22 minutes

In this lesson

  • Count arrangements with restrictions by filling the restricted places first.
  • Count objects that must stay together or apart with the block and gap methods.
  • Count "at least one" selections by the complement and confirm the result by cases.

The idea

The plan for any counting problem

A counting problem usually adds one twist to the formulas of permutations and combinations: a digit that cannot be zero, two people who refuse to sit next to each other, a team that needs at least one person of some kind. Four tools handle nearly all of these:

  1. Fill the restricted places first, then the free ones.
  2. Glue objects that must stay together into one block.
  3. Split into separate cases and add them (the sum rule).
  4. Count the complement: everything, minus what you do not want.

Then check with a second tool. Tools 3 and 4 are natural partners: a complement answer can be confirmed by adding the cases, and the other way round.

Restricted places first

If one position has a condition, deal with it before the others, while the number of choices is still easy to see. To count three-digit numbers with distinct digits, start with the hundreds digit: it cannot be 0, so 9 choices; then the tens digit has 9 (any digit except the one used, and 0 is now allowed); then the units digit has 8. That gives 9×9×8=6489 \times 9 \times 8 = 648. Starting from the units digit would leave you unsure whether 0 was still available for the hundreds place.

Together: the block method

When two people must sit side by side, tie them into one block. With 6 people in a row and two who must be adjacent, you arrange 5 units (the block and 4 others) in 5!=1205! = 120 ways, and the two inside the block can stand in 2!=22! = 2 orders: 240240 arrangements. Forgetting the factor 22 for the inside of the block is the commonest slip.

Apart: complement or gaps

"Must not be adjacent" is the complement of "must be adjacent": all arrangements minus the adjacent ones. With 6 people that is 720−240=480720 - 240 = 480.

The gap method gives the same answer by a second route. Arrange the other 4 people first: 4!=244! = 24 ways. They leave 5 gaps: one before the first person, three between neighbours and one after the last. Put the two people into 2 different gaps, in order: 5×4=205 \times 4 = 20. Total 24×20=48024 \times 20 = 480. Two routes, one answer: you can trust it.

"At least one": go round the back

"At least one" covers many cases (exactly one, exactly two, and so on), but its complement is a single case: none. So

at least one=all−none.\text{at least one} = \text{all} - \text{none}.

For a 4-person team from 5 women and 4 men with at least one woman: all teams (94)=126\binom{9}{4} = 126, teams with no woman (44)=1\binom{4}{4} = 1, so 125125.

The overcounting trap in "at least one"

A tempting shortcut is "choose the one woman who must be there, then choose the rest from everybody": 5×(83)=5×56=2805 \times \binom{8}{3} = 5 \times 56 = 280. It is far too big, more than the 126 teams that exist at all. A team with two women is counted twice, once for each woman playing "the required one". Whenever your answer exceeds the total with no restriction, a case has been counted more than once.

Cases, and when to add

Split by a feature that separates the outcomes cleanly, such as the number of women, the last digit or the first letter. Every outcome must land in exactly one case. Then add. Inside each case, use the product rule.

Counting digits and numbers

Numbers bring their own restrictions. A leading digit cannot be 0. "Even" fixes the last digit to 0, 2, 4, 6 or 8, and when digits must be distinct, 0 in the last place changes the count for the first place, so even numbers with distinct digits often need two cases: last digit 0, and last digit 2, 4, 6 or 8.

A sense of size

Before choosing, compare your answer with the total without any restriction. A restricted count must be smaller; a complement must be smaller still when the unwanted case is rare. Rough size checks like these catch most errors on a test where there is no calculator and no going back once you move to the next screen.

Worked examples

Example 1: Three-digit numbers with at least one 7

How many whole numbers from 100 to 999 contain the digit 7 at least once?

  1. All three-digit numbers: 999−100+1=900999 - 100 + 1 = 900.

  2. Complement, no 7 at all: the hundreds digit avoids 0 and 7, so 8 choices; the tens and units digits avoid 7, so 9 choices each. 8×9×9=6488 \times 9 \times 9 = 648.

  3. At least one 7: 900−648=252900 - 648 = 252.

  4. Check by cases on the number of 7s. Exactly one 7: in the hundreds place 1×9×9=811 \times 9 \times 9 = 81; in the tens place 8×1×9=728 \times 1 \times 9 = 72; in the units place 8×9×1=728 \times 9 \times 1 = 72; together 225. Exactly two 7s: hundreds and tens 1×1×9=91 \times 1 \times 9 = 9, hundreds and units 99, tens and units 8×1×1=88 \times 1 \times 1 = 8; together 26. Exactly three: 1. Total 225+26+1=252225 + 26 + 1 = 252.

Answer

252 numbers. A common wrong answer is 100+90+90=280100 + 90 + 90 = 280: it adds the numbers with a 7 in the hundreds, tens and units places, so 177, 707, 777 and the like are counted more than once.

Example 2: Two friends in a row of five

Five people, including Anna and Bruno, sit in a row of five chairs. In how many arrangements are Anna and Bruno next to each other, and in how many are they apart?

  1. All arrangements: 5!=1205! = 120.

  2. Together: glue Anna and Bruno into one block, leaving 4 units to arrange in 4!=244! = 24 ways; inside the block they sit in 22 orders. 24×2=4824 \times 2 = 48.

  3. Apart, by the complement: 120−48=72120 - 48 = 72.

  4. Apart, by gaps: seat the other 3 people in 3!=63! = 6 ways, creating 4 gaps; put Anna and Bruno in 2 different gaps in order, 4×3=124 \times 3 = 12 ways. 6×12=726 \times 12 = 72, as before.

Answer

48 arrangements with them together, 72 with them apart. Forgetting the factor 2 inside the block gives 24 and then 96, both wrong.

Example 3: A team with at least two women

A team of 4 is chosen from 5 women and 4 men. How many teams contain at least two women?

  1. Cases by the number of women. Two women and two men: (52)(42)=10×6=60\binom{5}{2}\binom{4}{2} = 10 \times 6 = 60. Three women and one man: (53)(41)=10×4=40\binom{5}{3}\binom{4}{1} = 10 \times 4 = 40. Four women: (54)=5\binom{5}{4} = 5.

  2. The cases cannot overlap, so add: 60+40+5=10560 + 40 + 5 = 105.

  3. Check with the complement. All teams: (94)=126\binom{9}{4} = 126. No woman: (44)=1\binom{4}{4} = 1. Exactly one woman: 5×(43)=205 \times \binom{4}{3} = 20. So 126−1−20=105126 - 1 - 20 = 105.

Answer

105 teams. The shortcut "choose two women, then any two others", 10×(72)=21010 \times \binom{7}{2} = 210, double-counts every team with three or four women.

Example 4: Even numbers from a set of digits

Using the digits 1, 2, 3, 4, 5, each at most once, how many four-digit even numbers can be formed?

  1. Fill the restricted place first: the units digit must be 2 or 4, so 2 choices.

  2. The other three places take any of the 4 remaining digits in order: 4×3×2=244 \times 3 \times 2 = 24.

  3. Total 2×24=482 \times 24 = 48.

  4. Check by symmetry: all four-digit numbers with distinct digits from the set number 5×4×3×2=1205 \times 4 \times 3 \times 2 = 120, and each digit is equally likely to end up in the units place, so 25\frac{2}{5} of them end in 2 or 4: 25×120=48\frac{2}{5} \times 120 = 48.

Answer

48 numbers. Starting from the thousands digit (5×4×3×…5 \times 4 \times 3 \times \dots) makes the number of even choices left for the last place depend on what was used, which is where errors creep in.

Common traps

  • Choosing "the required one" first

    For "at least one woman", choosing one woman and then any others counts a team with ww women ww times. Use the complement (all minus none) or split into exact cases. If your count is larger than the unrestricted total, you have fallen into this trap.

  • Forgetting the order inside a block

    Gluing two people together makes one unit for the outer arrangement, but the two still have 2!2! orders inside (three people glued together have 3!=63! = 6). Multiply by it every time.

  • Letting 0 lead a number

    A four-digit number cannot start with 0. Fill the leading place first, or count all strings and subtract those that begin with 0. When digits must be distinct and the number must be even, split on whether the last digit is 0.

  • Cases that overlap

    Cases may only be added if every outcome lands in exactly one of them. "Contains a 7 in the tens place" and "contains a 7 in the units place" overlap (77 counts in both), so adding them overcounts. Split on something exact, such as the number of 7s.

Check yourself

Answer each question before you open its answer.

Question 1: Codes with a repeated digit

Counting problems

A lock code is a string of three digits from 0 to 9 (codes such as 007 are allowed). How many codes contain at least one digit more than once?

  1. A.270
  2. B.280
  3. C.300
  4. D.720
Show the answer

Answer: B. 280

Working

All codes: 103=100010^3 = 1000. Codes with three different digits: 10×9×8=72010 \times 9 \times 8 = 720. At least one repeat: 1000−720=2801000 - 720 = 280. Check by cases: exactly two equal digits, choose the pair of places (3 ways), the repeated digit (10) and the other digit (9): 270; all three equal: 10. Total 280.

Why the other options are wrong

  • A. Counts codes with exactly two equal digits (3×10×93 \times 10 \times 9) but leaves out the 10 codes whose three digits are all equal.
  • C. Adds the three cases "first two equal", "first and last equal", "last two equal", 100 each, without removing overlaps: a code like 444 is counted three times.
  • D. This is the number of codes with three different digits, the complement of what was asked.

What carries over

For "at least one repeat", subtract the all-different count from the total, then confirm with exact cases.

Question 2: Two books apart

Counting problems

Six different books are placed in a row on a shelf. In how many arrangements are two particular books, an atlas and a dictionary, not next to each other?

  1. A.240
  2. B.360
  3. C.480
  4. D.600
Show the answer

Answer: C. 480

Working

All arrangements: 6!=7206! = 720. Together: a block plus 4 books is 5 units, 5!=1205! = 120 ways, times 2 orders inside the block, so 240. Apart: 720−240=480720 - 240 = 480. Check with gaps: arrange the other 4 books in 2424 ways, leaving 5 gaps; place the atlas and the dictionary in 2 different gaps in 5×4=205 \times 4 = 20 ways; 24×20=48024 \times 20 = 480.

Why the other options are wrong

  • A. This is the number of arrangements in which the two books are together: 5!×25! \times 2.
  • B. Half of 6!=7206! = 720, as if "together" and "apart" were equally likely. They are not: there are 240 together and 480 apart.
  • D. Subtracts only 5!=1205! = 120 for the together case, forgetting that the glued books can stand in two orders.

What carries over

Count "apart" as all minus together, and confirm with the gap method.

Question 3: At least one law student

Counting problems

A team of 3 is chosen from 6 economics students and 4 law students. How many teams include at least one law student?

  1. A.20
  2. B.60
  3. C.100
  4. D.144
Show the answer

Answer: C. 100

Working

All teams: (103)=120\binom{10}{3} = 120. Teams with no law student: (63)=20\binom{6}{3} = 20. At least one: 120−20=100120 - 20 = 100. Check by cases: one law student 4×15=604 \times 15 = 60, two (42)×6=36\binom{4}{2} \times 6 = 36, three (43)=4\binom{4}{3} = 4; total 100100.

Why the other options are wrong

  • A. This is (63)\binom{6}{3}, the number of teams with no law student: the complement, not the answer.
  • B. Counts only the teams with exactly one law student, 4×(62)4 \times \binom{6}{2}; teams with two or three law students also qualify.
  • D. Chooses "the" law student first and then any 2 of the other 9, 4×364 \times 36. A team with two or three law students is counted two or three times.

What carries over

At least one equals all minus none; a larger answer than the unrestricted total signals double counting.

Key points

  • Fill the restricted places first, then the free ones.

  • Together: glue into a block and multiply by the orders inside it. Apart: all minus together, or the gap method.

  • At least one equals all minus none; never choose "the required one" and then the rest.

  • Add cases only when every outcome falls in exactly one of them, and check by a second route.

All questions here are original and written for UniExamer; none comes from the test maker.

Written by the UniExamer team with AI assistance. Every worked example and check question was re-solved by an independent checker before publication. No subject expert has reviewed this lesson yet. If you find a mistake, write to support@uniexamer.com.

Poćwicz ten temat

Nowe pytania z tej umiejętności, z rozwiązaniami. Ćwiczenia wymagają Single Exam Pass lub Plus.