The 3 best practical examples of inclusion-exclusion principle in real problems
Why start with examples of 3 practical examples of inclusion-exclusion principle?
Most people first meet the inclusion-exclusion principle as a formula to memorize:
[
|A \cup B| = |A| + |B| - |A \cap B|,
]
and later for three sets,
[
|A \cup B \cup C| = |A| + |B| + |C| - |A \cap B| - |A \cap C| - |B \cap C| + |A \cap B \cap C|.
]
That’s fine, but it’s dry. The best examples are the ones where you feel why you’re adding and subtracting. So instead of starting with definitions, we’ll start with three anchor problems you can picture: students in classes, survey data, and software features. These are the core examples of 3 practical examples of inclusion-exclusion principle that everything else in this article builds on.
Example 1: Counting students in overlapping classes
Let’s begin with a classic, but give it a realistic spin.
A high school tracks enrollment in three advanced courses:
- AP Calculus (set A)
- AP Physics (set B)
- AP Computer Science (set C)
The registrar reports:
- 60 students in Calculus
- 45 students in Physics
- 40 students in Computer Science
- 20 in both Calculus and Physics
- 15 in both Calculus and Computer Science
- 10 in both Physics and Computer Science
- 5 students taking all three courses
The principal asks: How many distinct students are in at least one of these three classes?
This is the textbook example of 3 practical examples of inclusion-exclusion principle in education data. If we just added 60 + 45 + 40, we’d double-count students in multiple classes.
Using inclusion-exclusion for three sets:
[
|A \cup B \cup C| = |A| + |B| + |C|
- |A \cap B| - |A \cap C| - |B \cap C|
- |A \cap B \cap C|.
]
Plug in the numbers:
[
|A \cup B \cup C| = 60 + 45 + 40 - 20 - 15 - 10 + 5 = 105.
]
So 105 distinct students are in at least one advanced course.
Why this works:
- First, we add all three course enrollments.
- That double-counts each pair-overlap, so we subtract each intersection of two courses.
- But now the 5 students in all three classes were subtracted three times (once in each pair), after being added three times. Net effect so far: they’re counted 0 times. So we add them back once.
This is one of the best examples of how the principle naturally corrects double- and triple-counting.
Real-world angle: School districts and universities constantly aggregate overlapping enrollments, majors, and program participation. Institutional research offices use inclusion-exclusion logic even when they don’t name it. For a sense of how complex enrollment reporting can get, check out the data tables from the National Center for Education Statistics.
Example 2: Survey data with multiple responses (media habits)
Surveys are packed with overlapping categories. Think of a 2024 media survey of 500 adults that asks which platforms they used in the last week:
- Streaming video (A)
- Social media (B)
- Online news sites (C)
Suppose the results are:
- 350 used streaming video
- 400 used social media
- 280 used online news
- 320 used both streaming and social media
- 200 used both streaming and news
- 230 used both social media and news
- 180 used all three
We want: How many people used at least one of these? This is another clean example of 3 practical examples of inclusion-exclusion principle, now in a survey context.
Apply the formula:
[
|A \cup B \cup C| = 350 + 400 + 280 - 320 - 200 - 230 + 180.
]
Compute step by step:
- Sum of singles: 350 + 400 + 280 = 1,030
- Subtract pair overlaps: 1,030 - 320 - 200 - 230 = 280
- Add triple overlap: 280 + 180 = 460
So 460 people used at least one of the three types of platforms.
Notice something interesting: the survey had 500 people, so 500 − 460 = 40 people did not use any of these three in the last week.
This is exactly how analysts reconcile overlapping behaviors in large-scale surveys, like those from the Pew Research Center. When you see a chart that says “X% used at least one of these,” there’s often inclusion-exclusion logic behind the scenes.
Example 3: Users missing software features or permissions
Now let’s flip the perspective. Instead of counting who has something, we count who is missing at least one requirement.
Imagine a company rolling out a new internal app in 2025. Each employee account needs three permissions:
- Read access (R)
- Write access (W)
- Admin access (A)
There are 1,000 employee accounts. The IT team runs an audit and finds:
- 150 accounts missing read access
- 200 accounts missing write access
- 80 accounts missing admin access
- 50 missing both read and write
- 30 missing both read and admin
- 40 missing both write and admin
- 20 missing all three
Question: How many accounts are misconfigured — that is, missing at least one of the three permissions?
Here, define:
- X = set of accounts missing read
- Y = set of accounts missing write
- Z = set of accounts missing admin
We want |X ∪ Y ∪ Z|, which is again a direct example of 3 practical examples of inclusion-exclusion principle.
Apply the formula:
[
|X \cup Y \cup Z| = |X| + |Y| + |Z| - |X \cap Y| - |X \cap Z| - |Y \cap Z| + |X \cap Y \cap Z|.
]
Plug in:
[
|X \cup Y \cup Z| = 150 + 200 + 80 - 50 - 30 - 40 + 20.
]
Compute:
- Sum of singles: 150 + 200 + 80 = 430
- Subtract pair overlaps: 430 - 50 - 30 - 40 = 310
- Add triple overlap: 310 + 20 = 330
So 330 accounts are misconfigured. That means 1,000 − 330 = 670 accounts have all three permissions.
This kind of logic shows up in access audits, compliance checks, and security posture reports. Modern security frameworks, like those promoted by NIST, emphasize understanding overlapping vulnerabilities and missing controls. Inclusion-exclusion gives a clean way to count how many systems or accounts are affected by at least one problem.
More real examples: inclusion-exclusion beyond the classroom
Those three anchor problems are the classic examples of 3 practical examples of inclusion-exclusion principle, but the same pattern keeps reappearing. Here are several more situations where the principle quietly does the heavy lifting.
4. Counting students who failed at least one subject
A university tracks failures in three core first-year courses:
- Calculus (F₁)
- Physics (F₂)
- Chemistry (F₃)
In a cohort of 1,200 students, suppose:
- 180 failed Calculus
- 150 failed Physics
- 130 failed Chemistry
- 60 failed both Calculus and Physics
- 50 failed both Calculus and Chemistry
- 40 failed both Physics and Chemistry
- 25 failed all three
How many students failed at least one course?
Again, use inclusion-exclusion on F₁, F₂, F₃:
[
|F_1 \cup F_2 \cup F_3| = 180 + 150 + 130 - 60 - 50 - 40 + 25.
]
Compute:
- Singles: 180 + 150 + 130 = 460
- Subtract pairs: 460 - 60 - 50 - 40 = 310
- Add triple: 310 + 25 = 335
So 335 students failed at least one of the three subjects. This is not only a math exercise; it’s the kind of number an academic affairs office might use to target support resources.
5. Network reliability: devices with at least one failed component
Consider a small data center in 2024 with 300 servers. Each server has three critical components:
- Power supply (P)
- Network card (N)
- Storage drive (S)
Over a year, the admin logs failures and finds:
- 45 servers had a power failure
- 60 had a network card failure
- 30 had a storage failure
- 20 had both power and network failures
- 10 had both power and storage failures
- 15 had both network and storage failures
- 5 had all three failures
Question: How many servers experienced at least one critical failure?
This is a clean example of 3 practical examples of inclusion-exclusion principle in reliability engineering.
Apply the formula to sets P, N, S:
[
|P \cup N \cup S| = 45 + 60 + 30 - 20 - 10 - 15 + 5.
]
Compute:
- Singles: 45 + 60 + 30 = 135
- Subtract pairs: 135 - 20 - 10 - 15 = 90
- Add triple: 90 + 5 = 95
So 95 servers had at least one critical failure that year.
Engineers who work with reliability and fault-tolerance often use more advanced probabilistic versions of inclusion-exclusion, but the counting logic is the same. For background on reliability concepts, the materials from MIT OpenCourseWare are a good starting point.
6. Data cleaning: records with at least one error type
In data science, you constantly face overlapping error categories. Imagine a 2025 customer database with 50,000 records. A quality audit flags three types of issues:
- Missing email (E)
- Invalid phone format (P)
- Suspicious address (A)
Suppose the audit finds:
- 8,000 records with missing email
- 6,000 with invalid phone
- 4,500 with suspicious address
- 2,500 with both missing email and invalid phone
- 1,800 with missing email and suspicious address
- 1,200 with invalid phone and suspicious address
- 900 with all three problems
Question: How many records have at least one issue?
Apply inclusion-exclusion to E, P, A:
[
|E \cup P \cup A| = 8{,}000 + 6{,}000 + 4{,}500 - 2{,}500 - 1{,}800 - 1{,}200 + 900.
]
Compute:
- Singles: 8,000 + 6,000 + 4,500 = 18,500
- Subtract pairs: 18,500 - 2,500 - 1,800 - 1,200 = 13,000
- Add triple: 13,000 + 900 = 13,900
So 13,900 records have at least one problem.
This is one of the best examples for data professionals because it mirrors what they do with real datasets: count how many rows are affected by at least one of several error conditions, without double-counting overlaps.
7. Password policy violations
Security teams love rules; users, not so much. Say a company in 2024 enforces three password rules:
- Must be at least 12 characters (C)
- Must include a digit (D)
- Must include a special character (S)
During an audit of 5,000 accounts, the team finds violations:
- 600 passwords too short
- 900 missing a digit
- 750 missing a special character
- 300 both too short and missing a digit
- 250 both too short and missing a special character
- 400 missing both digit and special character
- 150 violating all three rules
Question: How many users violate at least one password rule?
Let V₁, V₂, V₃ be the three violation sets. Then:
[
|V_1 \cup V_2 \cup V_3| = 600 + 900 + 750 - 300 - 250 - 400 + 150.
]
Compute:
- Singles: 600 + 900 + 750 = 2,250
- Subtract pairs: 2,250 - 300 - 250 - 400 = 1,300
- Add triple: 1,300 + 150 = 1,450
So 1,450 users violate at least one rule.
Again, this is inclusion-exclusion quietly powering a real audit metric.
8. At least one event in probability
So far, all our examples of 3 practical examples of inclusion-exclusion principle have been pure counting. But the same structure works in probability.
Suppose three independent monitoring systems detect anomalies in a factory line:
- System A triggers with probability 0.30
- System B with probability 0.25
- System C with probability 0.20
Assume you also know the joint probabilities:
- P(A and B) = 0.12
- P(A and C) = 0.08
- P(B and C) = 0.06
- P(A and B and C) = 0.04
What’s the probability that at least one system triggers on a given day?
In probability form, inclusion-exclusion says:
[
P(A \cup B \cup C) = P(A) + P(B) + P(C) - P(A \cap B) - P(A \cap C) - P(B \cap C) + P(A \cap B \cap C).
]
Plug in:
[
P(A \cup B \cup C) = 0.30 + 0.25 + 0.20 - 0.12 - 0.08 - 0.06 + 0.04.
]
Compute:
- Singles: 0.30 + 0.25 + 0.20 = 0.75
- Subtract pairs: 0.75 - 0.12 - 0.08 - 0.06 = 0.49
- Add triple: 0.49 + 0.04 = 0.53
So there’s a 53% chance that at least one system triggers on a given day.
This is the same structure as all the earlier counting problems; the only difference is that we’re adding and subtracting probabilities instead of counts.
How to recognize when to use inclusion-exclusion
By now we’ve walked through multiple examples of 3 practical examples of inclusion-exclusion principle across education, surveys, IT, networks, and security. A natural question is: When should you reach for this tool?
Here are the typical signals:
- You’re asked for “at least one of these” — at least one course, one failure, one permission missing, one rule violated.
- You have counts (or probabilities) for individual sets and their overlaps.
- A naive sum of categories would clearly double-count some individuals, machines, or records.
When those three conditions line up, inclusion-exclusion is usually the right move.
If you go beyond three sets, the pattern continues: add all single sets, subtract all pair intersections, add all triple intersections, subtract all quadruple intersections, and so on. For a more formal treatment, any standard discrete math or combinatorics text from a university site (for example, many courses listed at Harvard’s math department or similar programs) will spell out the general formula.
FAQ: common questions about inclusion-exclusion
Q1. Can you give a quick example of inclusion-exclusion with just two sets?
Yes. Suppose 80 students play soccer, 50 play basketball, and 20 play both. If you want the number who play at least one of the two sports, you compute:
[
80 + 50 - 20 = 110.
]
You subtract 20 because those students were counted twice in the sum 80 + 50.
Q2. Why do we add the triple intersection back in the examples of 3 practical examples of inclusion-exclusion principle?
For three sets A, B, C, elements in all three sets are:
- Counted three times when you add |A| + |B| + |C|.
- Then subtracted three times when you subtract the pair intersections |A ∩ B|, |A ∩ C|, |B ∩ C|.
So after those two steps, they’re counted 0 times. To fix that, you add |A ∩ B ∩ C| once.
Q3. Do I always need all the intersection sizes to use inclusion-exclusion?
For exact answers, yes. You need the sizes of the single sets, all pair intersections, and the triple intersection for the three-set case. In some applications, people approximate by ignoring very small intersections, but then the result is only an estimate.
Q4. Are there real examples where inclusion-exclusion is used at scale?
Definitely. Examples include:
- Estimating how many people meet at least one health-risk criterion in public health studies (see large survey work from agencies like the CDC).
- Counting users affected by at least one of several software bugs.
- Measuring how many database rows are impacted by at least one data-quality rule.
The principle is the same as in the classroom examples; only the scale and context change.
Q5. How do these 3 practical examples connect to more advanced combinatorics?
They’re the entry point. Once you’re comfortable with the examples of 3 practical examples of inclusion-exclusion principle, you can extend the idea to more sets, to probabilities, and to more abstract problems like counting permutations with restrictions (e.g., derangements). The mental pattern — add everything, subtract overlaps, then fix what you overcorrected — stays exactly the same.
Related Topics
The best examples of 3 examples of the principle of mathematical induction (plus more)
The 3 best practical examples of inclusion-exclusion principle in real problems
Modern examples of probabilistic method in combinatorics
Real-world examples of fundamentals of combinations
The 3 best practical examples of pigeonhole principle (with extra real-world twists)
Explore More Combinatorial Problem Solving
Discover more examples and insights in this category.
View All Combinatorial Problem Solving