ELI5: Explain Like I'm 5

Inclusion–exclusion principle

Imagine you have three different colored candies: red, blue, and green. You want to know how many total candies you have.

If you count all of the red candies, you get 4.

If you count all of the blue candies, you get 6.

If you count all of the green candies, you get 5.

So if you just add those numbers together, you might think you have 15 candies in total.

But wait! A few of the candies are actually two colors. You have two candies that are both red and blue, and one candy that is both blue and green.

If you count those candies, you're double-counting them in your total. So you need to subtract them from the total.

Now you should have:

- 4 red candies
- 6 blue candies
- 5 green candies
- 2 candies that are both red and blue
- 1 candy that is both blue and green

So to get the total number of candies, you add up the number of candies in each category, and then subtract the candies that are in two categories:

4 + 6 + 5 - 2 - 1 = 12

So you actually have 12 candies, not 15.

This is basically what the inclusion-exclusion principle is all about. When you're counting things that can fall into multiple categories, you might overcount some things. To correct for that, you need to subtract the things that fall into multiple categories.