In the previous units, we solved equations and inequalities to find values or ranges that satisfy given conditions. Now we change the question slightly: instead of finding the value, we ask how many possible cases there are.
Understand the basic principles of counting, and decide first what should be considered a different case.
Before using any formula, keep this order in mind.
- Counting asks how many choices, arrangements, or outcomes are possible.
- But before counting, we must decide what makes two cases different.
- The answer changes depending on whether repetition is allowed, whether identical objects exist, and whether order matters.
- When choices cannot happen at the same time, we use the sum rule.
- When choices happen in steps, we use the product rule.
- We should understand the mathematics first, then use Python lists only to verify the actual cases.
1. What does a counting problem ask?
A counting problem asks how many possible cases satisfy given conditions.
For example, suppose you can choose one lunch from:
- kimbap
- ramen
- pork cutlet
Then there are 3 possible lunch choices.
If you also choose one drink from:
- water
- juice
then we count pairs of one lunch and one drink. A tree diagram shows this naturally.
There are 6 final branches.
But before counting, we must ask a more important question.
What counts as a different case?
For example, is "kimbap + water" different from "water + kimbap"? In a lunch menu, usually they are the same choice. But in a password, changing order usually makes a different case.
So the first principle is this.
Counting begins by deciding the standard for distinctness.
2. The standard for distinctness comes first
Suppose we choose two cards from A, B, C.
If the order matters, then
because choosing A first and B second is different from choosing B first and A second.
If the order does not matter, then
because both mean that A and B were chosen.
The same physical choices can give different answers depending on the standard. Therefore, do not begin with a formula. Begin with these questions.
- Are the objects distinct?
- Can the same object be chosen again?
- Does order matter?
- Are the cases disjoint, or do they overlap?
Only after answering these questions should we count.
3. The sum rule
The sum rule applies when several choices are separated into cases that do not overlap.
Suppose a student chooses exactly one activity after school.
- Math club: 4 choices
- Science club: 3 choices
If the student chooses one club only, then the total number of choices is
This works because the two groups do not overlap. A choice cannot be both a math club choice and a science club choice at the same time.
So the sum rule is:
If cases do not overlap, add the numbers of cases.
When the cases overlap
If two groups overlap, we cannot simply add.
Suppose 12 students like soccer, 10 students like basketball, and 4 students like both.
If we add 12 and 10, students who like both are counted twice. So the number of students who like soccer or basketball is
The important idea is not the formula itself. The idea is:
If cases overlap, remove the duplicates.
The sum rule in its simple form works only when the cases are disjoint.
4. The product rule
The product rule applies when a choice is made in steps.
Suppose we choose one shirt and one pair of pants.
- 3 shirts
- 2 pants
For each shirt, there are 2 pants choices. So the total is
A tree diagram shows why multiplication appears.
For each of the 3 first choices, there are 2 second choices.
So the product rule is:
If a choice is made in steps, multiply the number of choices at each step.
However, we must be careful. The second number of choices may depend on the first choice. If it does, we count branch by branch.
For example, if the first choice affects what can be chosen next, we cannot blindly multiply by the same number. This idea is related to independence later, but here we only need the counting meaning:
Multiplication is safe when each branch has the same number of next choices, or when we explicitly count each branch.
5. Sum rule and product rule together
Many problems use both rules.
Suppose a student can choose one of the following routes.
- Route A: choose 1 of 2 buses, then 1 of 3 subway lines
- Route B: choose 1 of 4 direct buses
Route A has
cases. Route B has
cases. Since Route A and Route B are separate alternatives, add them.
Here the structure is:
- Within one route, choices happen in steps, so multiply.
- Between routes, alternatives do not overlap, so add.
6. Math first, code later
Python is useful for checking cases, but it should not replace the mathematical thinking. First decide the structure, then generate lists to verify.
Verify the sum rule with Python lists
math_club = ["M1", "M2", "M3", "M4"]
science_club = ["S1", "S2", "S3"]
all_choices = math_club + science_club
print(all_choices)
print(len(all_choices))
The list contains 7 choices.
Verify the product rule with Python lists
shirts = ["S1", "S2", "S3"]
pants = ["P1", "P2"]
outfits = []
for shirt in shirts:
for pant in pants:
outfits.append([shirt, pant])
print(outfits)
print(len(outfits))
This creates actual arrays such as ['S1', 'P1'], not just the number 6.
Generate route arrays
route_a_buses = ["bus1", "bus2"]
route_a_subways = ["subway1", "subway2", "subway3"]
route_b_direct = ["direct1", "direct2", "direct3", "direct4"]
cases = []
for bus in route_a_buses:
for subway in route_a_subways:
cases.append(["A", bus, subway])
for direct in route_b_direct:
cases.append(["B", direct])
for case in cases:
print(case)
print(len(cases))
This verifies that there are 10 route cases.
7. Common mistakes
Mistake 1. Adding overlapping cases
If two cases can happen together, simple addition double-counts some cases. Remove duplicates.
Mistake 2. Multiplying without checking the branches
If the first choice changes the number of later choices, count each branch carefully.
Mistake 3. Using a formula before deciding what is distinct
The same objects can produce different answers depending on whether order matters and whether repetition is allowed.
8. Summary
- Counting means finding the number of possible cases.
- Before counting, decide what makes cases distinct.
- Use the sum rule when cases do not overlap.
- If cases overlap, remove duplicates.
- Use the product rule when choices happen in steps.
- If earlier choices affect later choices, count branch by branch.
- Python lists can verify the actual cases after the mathematical structure is clear.
💬 댓글
이 글에 대한 의견을 남겨주세요