Learn

The choices we have seen till now are from disjoint groups. For example, the same food item is not both a crust and a topping. The two groups are independent of each other. Let us look at another example.

In a group of 100 people, 75 like cold drinks and 45 like hot drinks. Each person likes at least one of the two drinks. How many like both? This is easy to solve using the set notation.

The principle of inclusion and exclusion (PIE) is a counting technique that computes the number of elements that satisfy at least one of several properties.

For two sets A and B, the principle states that

|A ∪ B| = |A| + |B| − |A ⋂ B|

Let us try to apply this principle to our hot/cold drinks problem. Let C be the set of people who like cold drinks and H be the set of people who like hot drinks.

As stated in the question, |C ∪ H| = 100, |C| = 75, |H| = 45

Using PIE, |C ⋂ H| = |C| + |H| − |C ∪ H| = 75 + 45 - 100 = 20

20 people like both hot and cold drinks.

Instructions

There are two groups in an orchestra: the strings and the woodwinds. Each student belongs to at least one of the two groups. The number of students in strings is 25, the number of students in woodwinds is 40. Of these, 10 are members of both strings and woodwinds. What is the total number of students in the orchestra?

Let S be the set of all strings-students and W, the set of all woodwinds-students. Then S ⋂ W would represent the students who play both.

|S| = 25, |W| = 40, |S ⋂ W| = 10

Applying the principle of inclusion and exclusion (PIE), the total number of students in the orchestra would be

|S ∪ W| = |S| + |W| - |S ⋂ W|

Answer: 25 + 40 - 10 = 55

Take this course for free

By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.
Already have an account?