# Constructive counting

In combinatorics, **constructive counting** is a counting technique that involves constructing an item belonging to a set. Along with the construction, one counts the total possibilities of each step and assembles these to enumerate the full set.

Along with casework and complementary counting, constructive counting is among the most fundamental techniques in counting. Familiarity with constructive counting is essential in combinatorics, especially in intermediate competitions.

## Contents

## Introductory Examples

### Example 1

*How many four-digit numbers are there?*

**Solution**: We can construct a four-digit by picking the first digit, then the second, and so on until the fourth. The first digit can be any number from one to nine — zero excluded, or else it ceases to have four digits — so it has possibilities choices. The other three digits can be any number from zero to ten, so they all have possibilities. We multiply the possibilities for each digit to arrive at our answer: .

Constructive counting is a simple concept, more so than its definition might lead one to think. All we did was think about constructing a four-digit number by choosing its digits, compute the possible numbers each digit can be, and multiply the resulting numbers.

This is a problem where constructive counting is not the simplest way to proceed. This next example is one where constructive counting is essential:

### Example 2

*How many lists of seven numbers are there such that each entry is between and inclusive and no two consecutive entries are equal?*

**Solution**: We can model this situation as a row of 7 boxes, like this: which we must populate with numbers between and including and ; the key restriction here is that no two boxes right next to each other can have the same number.

The first digit can be any number from to , of which there are such options. The second can be any of to too, with the sole exception of the previous digit. Regardless of whatever the first digit is, we know that it removes one option, so there are options for the second digit.

The exact same logic applies to the third digit; it can be any of the digits except the one before it, so it has options. This continues until the seventh digit, which means that digits to all have options. Hence, our answer is , as desired.

These two examples use options specifically based on digits, but this isn't the entire picture of constructive counting. The following example uses constructive counting in a different context.

### Example 3

*How many permutations of are there?*

**Solution**: We can model the question as a row of seven boxes, like this: which we have to populate with s and s. Using constructive counting is an idea, but there are multiple ways one might proceed with the construction. If we were to go like before and break the problem down by each box, we'd get a fairly messy solution.

Instead, one might think to break it down by first placing the s separately, then placing the s. Starting with the s, we must choose the boxes of their placement; because all the s are indistinguishable, this is given by , where is a combination. One example among many placements of the s is For the s, their position is actually predetermined by choosing the s; the only place the three s can go is in the three empty boxes, so we don't have to account for them after choosing the s. Thus, there are different permutations of , as required. .

Like in this problem, there are sometimes multiple independent ways to construct a set. In others, however, an alternative method is not apparent, as with the next example:

### Example 4

* 2001 AMC 12 Problem 16: A spider has one sock and one shoe for each of its eight legs. In how many different orders can the spider put on its socks and shoes, assuming that, on each leg, the sock must be put on before the shoe?*

**Solution**: Note that each leg has one designated shoe and a designated sock; each leg's shoe and sock belong to only that leg. The question is then only asking about the order in time in which it puts on all 16 socks and shoes. We can model the different orders as 16 boxes, where each box is populated with a certain sock or shoe, like this: Breaking up the problem by each box leads to a dead end. Instead, we can use a similar approach to example three to solve this problem — we can first choose two boxes in which each leg's sock-shoe pair is located, then we permute them. For the first leg, the location of its sock and shoe's two boxes are given by ; but on permuting them, we know that the sock appears first in the list, which implies that only one permutation exists.

So, there are just different places in which the first leg's sock and shoe can be located in the 16 boxes. By similar logic, the second leg has places in the boxes, the third has , and so on. The final answer is then the product of the leg's choices, which is Thus, our final answer is . .

This problem was much more challenging than the others mentioned thus far, but it's a lovely illustration of just how piercing a cleverly chosen construction can be to counting problems.

### Example 5

* 2004 AIME I Problem 6: An integer is called snakelike if its decimal representation satisfies if is odd and if is even. How many snakelike integers between 1000 and 9999 have four distinct digits?*

**Solution**: We construct the set of snakelike integers. All the recursive requirement is saying is that the second digit must be greater than the first and third, and the fourth must be greater than the third. But before we start construction, we must divide our investigation into several cases, based on whether we allow zeroes

**Case 1**: Snakelike integers with no zero. First, we choose the four integers. They must be between and inclusive, and no digit can be repeated, so the combination that describes this is . Next, we find out how many permutations of these digits keep the number snakelike. For simplicity, consider the case of , , , and . The total possibilities are This applies to all snakelike integers with no zero, which means there arrangements that keep the number snakelike. Thus we have snakelike integers with four distinct digits and no zero.

**Case 2**: Snakelike integers with one zero. First, we choose the other three integers, which by similar logic above is . Next, we permute these digits. Without loss of generality, let our other three digits be , , and . The total possibilities are Hence, there are snakelike integers with four distinct digits and one zero.

It's easy to see that introducing a second zero would mandate them being the first and third digits. However, this breaks our requirement that our integers must be between and , so there are no four-digit snakelike integers with two or more zeroes. Thus, our total is snakelike integers with four distinct digits, as desired. .

It's worth noting that as problem-solving ability becomes more advanced, there are fewer problems that can be solved by constructive counting alone; the list of examples terminates at a late-introductory level consequentially. At the same time, there are many, many more problems at a higher level where constructive counting is a crucial intermediate step, combined with other counting strategies to reach an answer.

## Intermediate Examples

These problems are more advanced than the introductory examples, requiring greater creativity to solve.

### Example 1

*Russia 1998: A 10-digit number is said to be interesting if its digits are all distinct and it is a multiple of 11111. How many interesting numbers are there?*

**Solution**: There doesn't seem to be a useful pattern in multiples of 11111 And even if there was one, it's not clear how to mediate it with the distinct digits condition. Thus, we look for additional restrictions that will help us count.

Let be any interesting number. Because has ten distinct digits, its digits must be an ordered arrangement of to used exactly once. From here, note that the sum of its digits, , is divisible by . This implies through divisibility rules that is a multiple of ; therefore, is a multiple of .

An idea from here is to utilize the special properties of — namely, that . The compells us to express as for some five-digit numbers and ; doing so gives that Both sides of this equation must be divisible by , which implies that is divisible by . It's easy to verify that even without this condition, the maximum of is , which is less than . Therefore, must be equal to .

This also interacts with the distinct digits property; namely, that the corresponding digits of and add to . For example , where . Thus, corresponding digits must come in pairs — which now enables us to construct and . We first place these pairs in (which places it in ), of which they can be in any order. There are then options for the pairs' positions. The only thing left is which number in each pair goes to and which to ; there are ways we can divvy a pair up, which means there are total possibilities.

But wait! This construction counts numbers that start with zero — something that violates the 10-digit condition — as being interesting numbers. Note that in our count, each digit is equally likely to be first; thus, of our numbers start with , and only of our count keeps the number ten-digit. Putting this all together, there are interesting numbers.