Discrete MathematicsCounting: Choices, Arrangements and Selections5 of 7
Counting: Choices, Arrangements and Selections · 5

Casework and Complementary Counting

Multiplying choices works when each slot has a fixed number of options, but many counting problems have rules where one choice changes what is left for the others.

1

When Choices Depend on Earlier Choices: Casework

Using the digits 1,2,3,4,1, 2, 3, 4, and 55 without repeating any digits, how many 33-digit numbers can we make that are greater than 300300 and even?

The first digit must be 3,4,\firstrole{3}, \trouble{4}, or 5\firstrole{5}, and the last digit must be 2\secondrole{2} or 4\trouble{4}. How many choices are left for the last slot depends on whether we already used 4\trouble{4} in the first slot:

When Choices Depend on Earlier Choices: Casework
1,  2,  3,  4,  51,\; 2,\; 3,\; 4,\; 5
3-digit numbers, no repeated digits\text{3-digit numbers, no repeated digits}
>300\htmlClass{lc-blue}{> 300}
even\htmlClass{lc-pink}{\text{even}}
numbers= ?\text{numbers} = \,?
Text solution
Case 1: Put 4\trouble{4} in the first slotPutting 4\trouble{4} into the first slot uses up one of the even digits, which forces 2\secondrole{2} into the last slot and leaves the 33 remaining digits (1,3,1, 3, and 55) for the middle slot.
1×3×1\displaystyle \firstrole{1} \times 3 \times \secondrole{1} =3\displaystyle = 3
Case 2: Put 3\firstrole{3} or 5\firstrole{5} in the first slotKeeping 4\trouble{4} out of the first slot leaves both even digits (2\secondrole{2} and 4\trouble{4}) available for the last slot, and leaves 33 unused digits for the middle slot.
2×3×2\displaystyle \firstrole{2} \times 3 \times \secondrole{2} =12\displaystyle = 12
Add the two casesEvery valid number either starts with 4\trouble{4} or starts with 3\firstrole{3} or 5\firstrole{5}, so we add the counts from the two cases.
3+12\displaystyle 3 + 12 =15\displaystyle = \wanted{15}

So there are 15\wanted{15} even 33-digit numbers greater than 300300 that can be made from 1,2,3,4,1, 2, 3, 4, and 55 without repeats.

Starting with 3\firstrole{3} or 5\firstrole{5} leaves both 2\secondrole{2} and 4\trouble{4} available for the last slot, whereas starting with 4\trouble{4} uses up an even digit and leaves only 1\secondrole{1} choice for the last slot:

Starting with 3 or 5 leaves both even digits for the last slot, while starting with 4 uses one up and cuts the tree in half.
2

Why Cases Cannot Overlap

Adding cases together only gives the right total when no outcome belongs to two cases at once. Using the letters A, B, and C with repeats allowed, how many 22-letter codes contain at least one A?

Why Cases Cannot Overlap
A,  B,  C\text{A},\; \text{B},\; \text{C}
repeats allowed\text{repeats allowed}
2-letter codes with at least one A\text{2-letter codes with at least one A}
Case 1: first letter A\htmlClass{lc-blue}{\text{Case 1: first letter A}}
A\htmlClass{lc-blue}{\text{A}}
Case 2: second letter A\htmlClass{lc-pink}{\text{Case 2: second letter A}}
A\htmlClass{lc-pink}{\text{A}}
codes= ?\text{codes} = \,?
Starts with A\htmlClass{lc-blue}{\text{Starts with A}}
AA\htmlClass{lc-orange}{\text{A}}\htmlClass{lc-orange}{\text{A}}
AB\htmlClass{lc-blue}{\text{A}}\text{B}
AC\htmlClass{lc-blue}{\text{A}}\text{C}
Ends with A\htmlClass{lc-pink}{\text{Ends with A}}
AA\htmlClass{lc-orange}{\text{A}}\htmlClass{lc-orange}{\text{A}}
BA\text{B}\htmlClass{lc-pink}{\text{A}}
CA\text{C}\htmlClass{lc-pink}{\text{A}}
3+3=6\htmlClass{lc-blue}{3} + \htmlClass{lc-pink}{3} = \htmlClass{lc-orange}{6}
A, not A\htmlClass{lc-blue}{\text{A, not A}}
AB\htmlClass{lc-blue}{\text{A}}\text{B}
AC\htmlClass{lc-blue}{\text{A}}\text{C}
not A, A\htmlClass{lc-pink}{\text{not A, A}}
BA\text{B}\htmlClass{lc-pink}{\text{A}}
CA\text{C}\htmlClass{lc-pink}{\text{A}}
A, A\htmlClass{lc-violet}{\text{A, A}}
AA\text{A}\text{A}
2+2+1=5\htmlClass{lc-blue}{2} + \htmlClass{lc-pink}{2} + \htmlClass{lc-violet}{1} = \htmlClass{lc-green}{5}
Text solution
Case 1: A in the first slot, not A in the second slotPutting A first (11 choice) and B or C second (22 choices) counts the codes with a single A at the start.
1×2\displaystyle 1 \times 2 =2\displaystyle = \firstrole{2}
Case 2: Not A in the first slot, A in the second slotPutting B or C first (22 choices) and A second (11 choice) counts the codes with a single A at the end.
2×1\displaystyle 2 \times 1 =2\displaystyle = \secondrole{2}
Case 3: A in both slotsPutting A into both slots counts the code AA\bothA{\text{AA}} once on its own.
1×1\displaystyle 1 \times 1 =1\displaystyle = \bothA{1}
Add the non-overlapping casesEvery code with at least one A falls into one and only one of these three cases.
2+2+1\displaystyle \firstrole{2} + \secondrole{2} + \bothA{1} =5\displaystyle = \wanted{5}

So there are 5\wanted{5} two-letter codes with at least one A, unlike the overlapping 3+3=6\firstrole{3} + \secondrole{3} = \fails{6} split that counts AA\fails{\text{AA}} twice.

3

Complementary Counting: Turning "Or" into "And"

Now let's ask the same question for 44-letter codes from A, B, and C, with repeats allowed: how many 44-letter codes contain at least one A?

Instead of splitting into cases for 1,2,3,\wanted{1, 2, 3}, or 4\wanted{4} A's, we can count all possible codes and subtract the one case we do not want:

Complementary Counting: Turning "Or" into "And"
A,  B,  C\text{A},\; \text{B},\; \text{C}
repeats allowed\text{repeats allowed}
4-letter codes with at least one A\text{4-letter codes with at least one A}
codes= ?\text{codes} = \,?
Text solution
Count all 44-letter codes with no restrictionsEach of the 44 slots can be A, B, or C.
3×3×3×3\displaystyle 3 \times 3 \times 3 \times 3 =81\displaystyle = 81
Count the unwanted codes with zero A'sLeaving out A gives 22 choices (B or C) for the first slot, and 22 for the second, and 22 for the third, and 22 for the fourth.
2×2×2×2\displaystyle 2 \times 2 \times 2 \times 2 =16\displaystyle = \fails{16}
Subtract the unwanted codes from the totalRemoving the codes with no A's leaves all the codes that have 1,2,3,\wanted{1, 2, 3}, or 4\wanted{4} A's.
81−16\displaystyle 81 - \fails{16} =65\displaystyle = \wanted{65}

So 65\wanted{65} of the 8181 four-letter codes contain at least one A.

4

Counting Repeats by Counting No Repeats

The same switch from "or" to "and" works when we want to count repeated digits. Using the ten digits 00 through 99, how many 44-digit PINs have at least one repeated digit?

Counting Repeats by Counting No Repeats
0,  1,  2,  3,  4,  5,  6,  7,  8,  90,\; 1,\; 2,\; 3,\; 4,\; 5,\; 6,\; 7,\; 8,\; 9
4-digit PINs with at least one repeated digit\text{4-digit PINs with at least one repeated digit}
4 4 1 94\,4\,1\,9
or\text{or}
4 7 4 74\,7\,4\,7
or\text{or}
8 2 8 88\,2\,8\,8
or\text{or}
5 5 5 55\,5\,5\,5
PINs= ?\text{PINs} = \,?
Text solution
Count all 44-digit PINsAny of the 1010 digits (00 through 99) can go into each of the 44 slots.
10×10×10×10\displaystyle 10 \times 10 \times 10 \times 10 =10,000\displaystyle = 10{,}000
Count the unwanted PINs with no repeated digitsFor all four digits to be different, each slot must avoid the digits already used in earlier slots.
10×9×8×7\displaystyle 10 \times 9 \times 8 \times 7 =5,040\displaystyle = \fails{5{,}040}
Subtract the no-repeat PINs from the totalEvery remaining PIN repeats at least one digit.
10,000−5,040\displaystyle 10{,}000 - \fails{5{,}040} =4,960\displaystyle = \wanted{4{,}960}

So there are 4,960\wanted{4{,}960} four-digit PINs with at least one repeated digit.

5

Using Complementary Counting and Casework Together

Sometimes switching to the opposite condition still leaves more than one unwanted case, so we use complementary counting and casework together. Still using A, B, and C with repeats allowed, how many 44-letter codes have at least two A's?

Using Complementary Counting and Casework Together
A,  B,  C\text{A},\; \text{B},\; \text{C}
repeats allowed\text{repeats allowed}
all 4-letter codes: 81\text{all 4-letter codes: } 81
0 A’s\text{0 A's}
1 A\text{1 A}
2 A’s\text{2 A's}
3 A’s\text{3 A's}
4 A’s\text{4 A's}
codes with\text{codes with}
at least\text{at least}
two A’s= ?\text{two A's} = \,?
Text solution
Count all 44-letter codesEach of the 44 slots has 33 choices (A, B, or C).
3×3×3×3\displaystyle 3 \times 3 \times 3 \times 3 =81\displaystyle = 81
Unwanted Case 1: Zero A'sEvery slot must be B or C, giving 22 choices per slot.
2×2×2×2\displaystyle 2 \times 2 \times 2 \times 2 =16\displaystyle = \fails{16}
Unwanted Case 2: Exactly one AThe single A can go into any of the 44 positions, and each position has 11 choice for the A slot and 22 choices (B or C) for each of the other three slots.
4×(1×2×2×2)\displaystyle 4 \times (1 \times 2 \times 2 \times 2) =4×8\displaystyle = 4 \times 8 =32\displaystyle = \fails{32}
Add the unwanted cases and subtract from the totalRemoving the codes with 0\fails{0} A's or 1\fails{1} A leaves the codes with 2,3,\wanted{2, 3}, or 4\wanted{4} A's.
81−(16+32)\displaystyle 81 - (\fails{16} + \fails{32}) =81−48\displaystyle = 81 - \fails{48} =33\displaystyle = \wanted{33}

So there are 33\wanted{33} four-letter codes with at least two A's.

The five cases (0,1,2,3,0, 1, 2, 3, or 44 A's) split all 8181 codes into non-overlapping groups, so the wanted cases and the unwanted cases always add to 8181:

Across all five non-overlapping cases, the codes we want and the codes we don't want always add up to all 81 codes.
6

Casework and Complementary Counting with Combinations

All our problems so far have filled ordered slots, so now let's choose an unordered group: from 5\firstrole{5} Programmers and 4\secondrole{4} Designers (99 people in all), how many 44-person teams have at least one Programmer?

Since order does not matter on a team, we use combinations C(n,k)C(n, k) to pick unordered groups all at once:

Casework and Complementary Counting with Combinations
5 Programmers\htmlClass{lc-blue}{5\text{ Programmers}}
4 Designers\htmlClass{lc-pink}{4\text{ Designers}}
pick a 4-person team\text{pick a 4-person team}
with at least one Programmer\text{with at least one Programmer}
teams= ?\text{teams} = \,?
Text solution
Method 1: Split into cases by the exact number of ProgrammersPick all Programmers for a case in one combination and all Designers in another, then add the four non-overlapping cases (1,2,3,\firstrole{1, 2, 3}, or 4\firstrole{4} Programmers).
C(5,1)×C(4,3)+C(5,2)×C(4,2)+C(5,3)×C(4,1)+C(5,4)×C(4,0)=20+60+40+5=125\displaystyle \begin{aligned} &\quad \firstrole{C(5,1)} \times \secondrole{C(4,3)} \\ &+ \firstrole{C(5,2)} \times \secondrole{C(4,2)} \\ &+ \firstrole{C(5,3)} \times \secondrole{C(4,1)} \\ &+ \firstrole{C(5,4)} \times \secondrole{C(4,0)} \\ &= 20 + 60 + 40 + 5 = \wanted{125} \end{aligned}
Method 2: Subtract the unwanted case from all possible teamsOut of all C(9,4)=126C(9,4) = 126 four-person teams, only C(4,4)=1\fails{C(4,4)} = \fails{1} team has 0\firstrole{0} Programmers and 4\secondrole{4} Designers.
C(9,4)−C(4,4)\displaystyle C(9,4) - \fails{C(4,4)} =126−1\displaystyle = 126 - \fails{1} =125\displaystyle = \wanted{125}

So there are 125\wanted{125} four-person teams with at least one Programmer (and for at least two Programmers, subtracting the 1\fails{1} zero-Programmer team and the 20\fails{20} one-Programmer teams gives 126−1−20=105126 - \fails{1} - \fails{20} = \wanted{105}).

Picking one "guaranteed" Programmer first and 33 of the remaining 88 people second counts every team with 2,3,\firstrole{2, 3}, or 4\firstrole{4} Programmers 2,3,\fails{2, 3}, or 4\fails{4} separate times, whereas grouping by the exact number of Programmers counts each team once:

Picking a Programmer first counts the same team once for each Programmer on it, while grouping by how many Programmers there are counts the team once.

Key concepts

When not to use casework

If the number of options in every step stays the same regardless of earlier choices, multiply straight across on a single line (forming a 33-digit number from 1,2,3,4,51, 2, 3, 4, 5 with no extra rules is simply 5×4×3=605 \times 4 \times 3 = \wanted{60}).

Dependent choices ("it depends" →\rightarrow Casework)

When an option can go in two restricted slots, put that overlapping option into its own case so the number of choices inside each case stays fixed (for even 33-digit numbers >300> 300 from 1,2,3,4,51, 2, 3, 4, 5, separate starting with 4\trouble{4}, 1×3×1=3\firstrole{1} \times 3 \times \secondrole{1} = 3, from starting with 3\firstrole{3} or 5\firstrole{5}, 2×3×2=12\firstrole{2} \times 3 \times \secondrole{2} = 12).

Non-overlapping cases

Define cases so no outcome can belong to two cases at once: either specify which slots hold the item (A, not A\firstrole{\text{A, not A}}; not A, A\secondrole{\text{not A, A}}; A, A\bothA{\text{A, A}}) or split by the exact count of the item (0,1,2,3,0, 1, 2, 3, or 44 A's).

Turning "ors" into "ands" ("at least" or "repeats" →\rightarrow Complementary counting)

Subtract the unwanted cases from the total whenever switching to the opposite condition turns multiple "or" cases into a single line of "ands" (44-letter codes from A, B, C with at least one A: 81−16=6581 - \fails{16} = \wanted{65}; 44-digit PINs with a repeat: 10,000−5,040=4,96010{,}000 - \fails{5{,}040} = \wanted{4{,}960}) or leaves fewer cases to count (at least two A's subtracts 0\fails{0} A's and 1\fails{1} A: 81−(16+32)=3381 - (\fails{16} + \fails{32}) = \wanted{33}).

Unordered groups with combinations

Never make a separate first step for a required member (C(5,1)×C(8,3)=280\firstrole{C(5,1)} \times C(8,3) = \fails{280} counts every team with multiple Programmers more than once). Either subtract the unwanted cases from all C(n,k)C(n, k) teams (C(9,4)−C(4,4)=126−1=125C(9,4) - \fails{C(4,4)} = 126 - \fails{1} = \wanted{125}) or add the cases for each exact number from each subgroup (C(5,1)×C(4,3)+…\firstrole{C(5,1)} \times \secondrole{C(4,3)} + \dots).

7

Practice

1

Using the digits 1,2,3,4,5,1, 2, 3, 4, 5, and 66 without repeating any digits, how many 33-digit numbers can you make that are greater than 400400 and odd?

List the allowed digits for the first slot (>400> 400) and the last slot (odd). Which digit shows up in both lists?

The first digit must be 4,5,\firstrole{4}, \trouble{5}, or 6\firstrole{6} and the last digit must be 1,3,\secondrole{1, 3}, or 5\trouble{5}. Do not multiply 3×4×3=363 \times 4 \times 3 = \fails{36} on a single line, because picking 5\trouble{5} first leaves only 2\secondrole{2} odd digits for the last slot instead of 3\secondrole{3}. Split into cases based on whether the first digit is 5\trouble{5}:
Case 1 (first digit is 5\trouble{5})1\firstrole{1} choice for the first slot (5\trouble{5}), 2\secondrole{2} remaining odd digits for the last slot (1\secondrole{1} or 3\secondrole{3}), and 44 remaining digits for the middle slot:
1×4×2\displaystyle \firstrole{1} \times 4 \times \secondrole{2} =8\displaystyle = 8
Case 2 (first digit is 4\firstrole{4} or 6\firstrole{6})2\firstrole{2} choices for the first slot (4\firstrole{4} or 6\firstrole{6}), all 3\secondrole{3} odd digits available for the last slot (1,3,\secondrole{1, 3}, or 5\trouble{5}), and 44 remaining digits for the middle slot:
2×4×3\displaystyle \firstrole{2} \times 4 \times \secondrole{3} =24\displaystyle = 24
Add the two cases
8+24\displaystyle 8 + 24 =32\displaystyle = \wanted{32}
2

A 55-letter code is made using the letters A, B, C, D, and E, with repeats allowed. How many codes contain at least one vowel (A or E)?

Instead of tracking which slots hold A or E, how many letters are left if a code uses no vowels at all?

Total 55-letter codesEach of the 55 slots has 55 choices:
5×5×5×5×5\displaystyle 5 \times 5 \times 5 \times 5 \times 5 =55\displaystyle = 5^5 =3,125\displaystyle = 3{,}125
Unwanted codes (no vowels)Leave out both vowels (A and E), which leaves the 33 consonants B, C, and D for every slot (be careful not to leave out only one vowel, which uses 45=1,0244^5 = 1{,}024 and gives 2,101\fails{2{,}101}, or pick a vowel for one slot first as 5×2×54=6,2505 \times 2 \times 5^4 = \fails{6{,}250}, which counts codes with multiple vowels more than once):
3×3×3×3×3\displaystyle 3 \times 3 \times 3 \times 3 \times 3 =35\displaystyle = 3^5 =243\displaystyle = \fails{243}
Subtract from the total
3,125−243\displaystyle 3{,}125 - \fails{243} =2,882\displaystyle = \wanted{2{,}882}
3

How many 44-digit numbers (from 1,0001{,}000 to 9,9999{,}999, so the first digit cannot be 00) have at least one repeated digit?

Count all 44-digit numbers first, then subtract the ones where all four digits are different, remembering which digit becomes allowed again in the second slot.

Total 44-digit numbersThe first slot has 99 choices (11 through 99) and the remaining three slots have 1010 choices each (00 through 99):
9×10×10×10\displaystyle 9 \times 10 \times 10 \times 10 =9,000\displaystyle = 9{,}000
Unwanted numbers (no repeated digits)The first slot has 99 choices (11 through 99). Because 00 can now be used along with the 88 unused nonzero digits, the second slot also has 99 choices, followed by 88 and 77 (using 88 choices for the second slot as 9×8×7×6=3,0249 \times 8 \times 7 \times 6 = 3{,}024 forgets 00 and gives the wrong answer 5,976\fails{5{,}976}):
9×9×8×7\displaystyle 9 \times 9 \times 8 \times 7 =4,536\displaystyle = \fails{4{,}536}
Subtract from the total
9,000−4,536\displaystyle 9{,}000 - \fails{4{,}536} =4,464\displaystyle = \wanted{4{,}464}
4

A 55-digit passcode is made using the digits 1,2,3,1, 2, 3, and 44, with repeats allowed. How many passcodes contain the digit 11 at least twice?

Out of the 0,1,2,3,4,0, 1, 2, 3, 4, or 55 times the digit 11 can appear, which two cases are the ones you do not want?

Total 55-digit passcodesEach of the 55 slots has 44 choices:
45\displaystyle 4^5 =1,024\displaystyle = 1{,}024
Unwanted Case 1 (no 11's)Each slot uses only 2,3,2, 3, or 44:
35\displaystyle 3^5 =243\displaystyle = \fails{243}
Unwanted Case 2 (exactly one 11)The single 11 can go into any of the 55 slots, and the other 44 slots each have 33 choices (2,3,2, 3, or 44). Be careful not to count only the case where 11 is in the first slot (1×34=811 \times 3^4 = 81, which misses the other 44 positions and gives the wrong answer 700\fails{700}):
5×34\displaystyle 5 \times 3^4 =5×81\displaystyle = 5 \times 81 =405\displaystyle = \fails{405}
Subtract both unwanted cases from the total
1,024−(243+405)\displaystyle 1{,}024 - (\fails{243} + \fails{405}) =1,024−648\displaystyle = 1{,}024 - \fails{648} =376\displaystyle = \wanted{376}
5

A club has 66 seniors and 55 juniors. How many ways can a 44-person committee be chosen if it must include at least one senior and at least one junior?

If a 44-person committee does not have at least one of each, what are the only two ways that committee can be made up?

Total 44-person committees from all 1111 members(Avoid picking 1\firstrole{1} senior and 1\secondrole{1} junior first and then 22 of the remaining 99 people, 6×5×C(9,2)=1,080\firstrole{6} \times \secondrole{5} \times C(9,2) = \fails{1{,}080}, which counts every valid committee multiple times.)
C(11,4)\displaystyle C(11,4) =330\displaystyle = 330
Unwanted committeesA committee breaks the rule if it has no juniors (all 4\firstrole{4} are seniors) or no seniors (all 4\secondrole{4} are juniors). Remember to subtract both all-one-group cases rather than only the all-senior case (330−15=315330 - \firstrole{15} = \fails{315}):
C(6,4)+C(5,4)\displaystyle \firstrole{C(6,4)} + \secondrole{C(5,4)} =15+5\displaystyle = \firstrole{15} + \secondrole{5} =20\displaystyle = \fails{20}
Subtract from the total
330−20\displaystyle 330 - \fails{20} =310\displaystyle = \wanted{310}
6

From a group of 66 doctors and 55 nurses, a 55-person medical team is chosen. How many teams have more doctors than nurses?

On a 55-person team, what exact numbers of doctors make the doctors outnumber the nurses?

Split into non-overlapping cases by the exact number of doctors on the 55-person team (3,4,\firstrole{3, 4}, or 5\firstrole{5} doctors):
Case 1 (3\firstrole{3} doctors and 2\secondrole{2} nurses)
C(6,3)×C(5,2)\displaystyle \firstrole{C(6,3)} \times \secondrole{C(5,2)} =20×10\displaystyle = \firstrole{20} \times \secondrole{10} =200\displaystyle = 200
Case 2 (4\firstrole{4} doctors and 1\secondrole{1} nurse)
C(6,4)×C(5,1)\displaystyle \firstrole{C(6,4)} \times \secondrole{C(5,1)} =15×5\displaystyle = \firstrole{15} \times \secondrole{5} =75\displaystyle = 75
Case 3 (5\firstrole{5} doctors and 0\secondrole{0} nurses)Do not forget that a team with 0\secondrole{0} nurses still has more doctors than nurses (leaving out this case stops at 200+75=275200 + 75 = \fails{275}):
C(6,5)×C(5,0)\displaystyle \firstrole{C(6,5)} \times \secondrole{C(5,0)} =6×1\displaystyle = \firstrole{6} \times \secondrole{1} =6\displaystyle = 6
Add the three cases
200+75+6\displaystyle 200 + 75 + 6 =281\displaystyle = \wanted{281}