A girl and a robot thinking together

Think it through · Start with a story

There are two hats and three scarves. The girl wants to know how many outfits she can make, so the robot lists every combination without skipping any.

Break Down the Process

Follow the numbered steps, then explain them in your own words
  1. Hat APair it with scarves 1, 2, and 3
  2. Hat BPair it with scarves 1, 2, and 3
  3. Count6 outfits total

Enumeration lists every allowed candidate and checks whether it satisfies the requirements.

Decide on the range first, then the order, to avoid repeats and omissions. Here, each hat must be paired with all three scarves.

01What Is Enumeration?

Enumeration means checking the candidates in a specified range one by one.

For example, find all numbers from 1 to 100 that are divisible by 7:

for (int i = 1; i <= 100; i++) {
    if (i % 7 == 0) {
        std::cout << i << ' ';
    }
}

02Is Enumeration Just Guessing?

No. Good enumeration has clearly defined candidates, a range, and checking rules.

What are you enumerating?

Candidate answers or states.

How far do you go?

The range must be complete.

How do you check?

Apply the problem’s conditions.

03Why Is Enumeration Important?

It is often the easiest method to get right, and it can help us understand the problem.

04How Can You Avoid Missing Cases?

For example, to enumerate from 1 through n:

for (int i = 1; i <= n; i++)

Check the boundaries first: should both 1 and n be included?

05What Does Nested Enumeration Mean?

for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
        // Check a pair of distinct elements
    }
}

This enumerates every pair of indices where i < j, avoiding checking the same pair twice.

06When Can Enumeration Be Too Slow?

When there are too many candidates, trying them all may require too much work.

For example, nested enumeration over n elements checks roughly n² combinations. The workload grows dramatically when n increases from 1,000 to 100,000.

What You Have Learned

  • Enumeration systematically checks candidates one by one.
  • It is not random guessing: define the range and the conditions.
  • Boundary choices determine whether cases are missed.
  • Nested enumeration can cover combinations, but the workload may grow quickly.
  • Enumeration is often a starting point for designing faster algorithms.

Next: Simulation: Make a Program Follow the Rules

Your Turn to Try

If you can use only scarves 1 and 2, how many outfits are possible?

Have you decided? Open to see the explanation

4 outfits. Each of the two hats can be paired with either scarf, so 2 × 2 = 4.