AZTest
Counting study guide · step 5 of 5

Inclusion-exclusion and complement counting problems

Sometimes it is easier to count what you do not want and subtract. For overlapping groups, inclusion-exclusion corrects for what was counted twice.

Key ideas

Watch out: “At least one digit 7” = all numbers − numbers with no 7.

Practise this step

5 questions from this step only, in 8 minutes: new numbers and stories every time, of exactly the types worked out below. Marked at the end, with every question worked out.

Start the 5-question quiz

Every question type in this step, worked out

11 types of question. Try each one yourself before you open the hint or the solution.

Example 1 · level 7

A class has 36 pupils. 14 sing in the choir, 15 play in the band, and 7 do both. How many pupils do neither?

a = 14b = 15c = 7n = 36?
Hint

Adding the choir and the band counts those who do both twice.

Worked solution
a = 14b = 15c = 7n = 36= 14
n−(a+b−c)
  1. At least one: 14 + 15 − 7 = 22
  2. Neither: 36 − 22 = 14

Answer: 14 pupils

Example 2 · level 7

A drawer holds plenty of socks in 6 colours. In the dark, how many socks must you take out to be sure of having 3 socks of the same colour?

?
Hint

Think of the unluckiest draw: as many of each colour as possible without reaching 3.

Worked solution
= 13
c(k−1)+1
  1. Unluckiest: 3 − 1 = 2 of each of the 6 colours, 6 × 2 = 12 socks
  2. One more makes 3 of one colour: 12 + 1 = 13

Answer: 13 socks

Example 3 · level 8

A committee of 4 is chosen from 13 people. Two of the people refuse to serve together. How many committees are possible?

C(13, 4)−C(11, 2)?
Hint

Count all committees, then take away those with both of the two in them.

Worked solution
C(13, 4)−C(11, 2)= 660
C(n,k)−C(n−2,k−2)
  1. All: C(13, 4) = 715
  2. With both: the other 2 from 11: C(11, 2) = 55
  3. Allowed: 715 − 55 = 660

Answer: 660 committees

Example 4 · level 8

How many whole numbers from 1 to 788 are divisible neither by 5 nor by 11?

788−157−71+14?
Hint

Count those divisible by 5 or by 11, taking care of the ones divisible by both, then take them away.

Worked solution
788−157−71+14= 574
N−(⌊Na⌋+⌊Nb⌋−⌊Nl⌋)
  1. By 5: 157; by 11: 71; by both, that is by 55: 14
  2. By 5 or 11: 157 + 71 − 14 = 214
  3. Neither: 788 − 214 = 574

Answer: 574 numbers

Example 5 · level 8

How many whole numbers from 1 to 880 are divisible by 2 or by 5?

Hint

Count each kind, then take away the numbers you counted twice.

Worked solution
  1. Divisible by 2: 440. Divisible by 5: 176.
  2. Divisible by both, so by 10: 88.
  3. 440 + 176 − 88 = 528

Answer: 528 numbers

Example 6 · level 8

What is the smallest number of people in a room that makes it certain that at least 6 of them were born in the same month?

?
Hint

There are 12 months. With as few as possible in each month, how many people fit before some month has 6?

Worked solution
= 61
12(k−1)+1
  1. Without 6 in any month: at most 6 − 1 = 5 per month, 12 × 5 = 60 people
  2. One more forces 6: 60 + 1 = 61

Answer: 61 people

Example 7 · level 8

How many 4-digit numbers do not contain the digit 9 anywhere?

8×9×9×9?
Hint

The first digit can be neither zero nor 9; every other digit only not 9.

Worked solution
8×9×9×9= 5832
8×9k−1
  1. First digit: 8 choices; each of the other 3: 9
  2. 8 × 9^3 = 8 × 729 = 5832

Answer: 5832 numbers

Example 8 · level 9

A team of 3 is picked from 7 boys and 3 girls. How many teams have at least two girls?

C(10, 3)−C(7, 3)−3·C(7, 2)?
Hint

Count all teams, then take away those with no girls and those with exactly one.

Worked solution
C(10, 3)−C(7, 3)−3·C(7, 2)= 22
C(b+g,k)−C(b,k)−g·C(b,k−1)
  1. All: C(10, 3) = 120
  2. No girls: C(7, 3) = 35; one girl: 3 × C(7, 2) = 63
  3. At least two: 120 − 35 − 63 = 22

Answer: 22 teams

Example 9 · level 9

A password has 5 characters, each one of 23 letters or a digit; characters may repeat. It must contain at least one digit. How many passwords are possible?

(23 + 10)^5−23^5?
Hint

Count all passwords, then take away those made of letters only.

Worked solution
(23 + 10)^5−23^5= 32,699,050
(L+10)k−Lk
  1. Characters: 23 + 10 = 33; all passwords: 33^5 = 39,135,393
  2. Letters only: 23^5 = 6,436,343
  3. With a digit: 39,135,393 − 6,436,343 = 32,699,050

Answer: 32,699,050 passwords

Example 10 · level 9

A keypad has 8 keys. A code is 6 key presses in a row, and a key may be pressed more than once. How many codes use some key more than once?

8^6−8! ÷ 2!?
Hint

Count all codes, then take away those in which every key is different.

Worked solution
8^6−8! ÷ 2!= 241,984
nk−n!(n−k)!
  1. All: 8^6 = 262,144
  2. All keys different: 8 × (8 − 1) × … = 20,160
  3. Some key repeats: 262,144 − 20,160 = 241,984

Answer: 241,984 codes

Example 11 · level 9

At a sports club, 16 members play football, 20 play tennis and 16 swim. 3 play football and tennis, 7 play football and swim, 6 play tennis and swim, and 2 do all three. How many members do at least one of the three?

F = 16T = 20S = 162?
Hint

Add the three groups, take away the three overlaps, and add back those in all three.

Worked solution
F = 16T = 20S = 162= 38
|A∪B∪C|=Σ|A|−Σ|A∩B|+|A∩B∩C|
  1. Groups: 16 + 20 + 16 = 52; overlaps: 3 + 7 + 6 = 16
  2. At least one: 52 − 16 + 2 = 38

Answer: 38 members

Ready for the quiz?

Check yourself on this step: 5 questions, 8 minutes.

Start the quiz

All steps of the Counting study guide

  1. The multiplication principle

    Outfits, routes through towns, number plates, PINs, menus and numbers made from digits.

  2. Arrangements (permutations)

    Photos with people at the ends, podiums, groups that stay together, round tables and books by subject.

  3. Choosing (combinations)

    Committees, teams from two groups, lines and triangles through points, lottery and handshakes.

  4. Paths, grids and sharing out

    Routes on a grid, via a shop or avoiding a crossing, tournaments, dominoes, rectangles in grids, stairs and boxes.

  5. Complements and overlaps

    Neither club, divisible by neither, three sports, repeated digits, passwords and the pigeonhole principle.

When every step feels easy, take the whole Counting test: 10 questions in 15 minutes.