Lesson Library> Combinatorics

Combinatorics

Introduction

My family and I have a tradition of going on a beach vacation every summer. During one of these trips, my sister and I happened upon a small ice cream stand. They offered $6$ flavours and we both decided to buy a cone with $3$ different flavours each. If I wanted at least one ball with the same flavour as my sister, then how many different ice creams could we have chosen?

We could try to figure this out by labeling the flavours with the numbers from $1$ to $6$. Some possible ice creams my sister could have chosen choose would then be $\{1,2,3\}$, $\{1,2,4\}$, $\{1,2,5\}$ and $\{1,2,6\}$. We might continue with $\{2,3,1\}$, $\{2,3,4\}$, $\{2,3,5\}$ and $\{2, 3, 6 \}$. But $\{1, 2, 3 \}$ and $\{2, 3, 1\}$ are in fact the same ice cream with the flavours in a different order! We have thus counted that ice cream twice. Even if we finally manage to figure out all the possible ice creams my sister could have chosen, we must also find out how many ice creams that my sister and I could have bought together. This becomes even more challenging when considering that I want at least one similar flavour as my sister had chosen.

Welcome to the topic of combinatorics! This is a branch of mathematics that is primarily about counting. Most of the time this is not a problem. We simply count one item at a time until we are done. But sometimes it's actually not that easy to know how to proceed, as shown by this example. In this lesson you’ll learn all the techniques you need to solve such problems!

Choices and Multiplication

Let's start with the basics. How do we calculate the number of possible outcomes when we have several choices to make? Have a look at the exercise below as an example.


Example 1

Michael has four different sweaters, three different pairs of trousers and six different pairs of shoes. How many outfits can he choose when he goes to school?

Solution

For each of the four sweaters, Michael can choose between three different pairs of trousers. He thus has $4\cdot3 = 12$ different combinations of sweaters and trousers. For each of these $12$ combinations, he can then choose between six different pairs of shoes. Michael thus has a total of $4\cdot3\cdot6 =\mathbf{72}$ different clothing combinations to choose from.


Hopefully you see the pattern here. If you can first choose between $x$ different options, and for each of those options you have additional $y$ options to choose from, then the total number of possible combinations is always the product of $x$ and $y$. It is very important that we multiply and not add. If we had added $4 + 3 + 6$, we would have got the number of garments that Michael has instead of the number of ways in which the garments can be combined.


Exercise 1

Miranda flips a coin five times. How many different outcomes can she get?

Each time the coin will show either heads or tails. Miranda can thus get $2\cdot2\cdot2\cdot2\cdot2 = 2^5 =\mathbf{32}$ different outcomes.


Exercise 2

How many "words" with three letters can we create by using the letters $a, b, c, d, e$ and $f$? (We ignore spelling, etc and we can use the same letter more than once).

We can select each letter in $6$ different ways so we can create a total of $6^3 =\mathbf{216}$ different words.


Exercise 3

How many "words" with three letters can we create by using the letters $a, b, c, d, e$ and $f$ if the first letter must be a vowel and we may not use the same letter more than once?

We can only choose between $2$ different alternatives to the first letter: either $a$ or $e$. Because we are not allowed to choose the same letter twice, we have five choices left for the second letter. Finally, we have four choices left for the third letter. In total, we can create $2\cdot5\cdot4 =\mathbf{40}$ different words.


Exercise 4

Gustav is strolling through town and gets a sudden craving for ice cream. He goes to the nearest ice cream shop where they have ten different flavours to choose from. You can have your ice cream served either in a cup or in a cone, and you can also choose to have your ice cream topped with sprinkles, caramel sauce or chocolate sauce. If Gustav wants one flavour for his ice cream, how many different ice creams could he buy?

Gustav has ten choices for the flavour of his ice cream, two different choices on how the ice cream should be served and four different choices for topping (he can also choose not to have any topping at all!). Gustav can thus buy $10 ​​\cdot2\cdot4 =\mathbf{80}$ different ice creams.


Arranging Objects

Let’s imagine that we have four different objects in a row: a square, a triangle, a circle and a pentagon. How many different arrangements can you create by placing these objects in different orders? The following are two possible ways of arranging these four objects.

In mathematics, such arrangements of objects are called permutations. For example, $\{3,1,2\}$ is a permutation of $\{1,2,3\}$ and vice versa. An easy way to determine the number of permutations of the four objects above is to imagine that we have four empty spaces in which we will place the objects. We then decide which object to put in which space.




We'll start with the square, then the triangle, then the circle and finally the pentagon. We have $4$ empty spaces to choose from for the square. Next, we only have $3$ empty places to choose from because the square will take up one of the spaces. If we then move on to the circle, this time we only have $2$ spaces to choose from. Last but not least, we have $1$ space left for the pentagon. The total number of ways to arrange the four objects is thus $4\cdot3\cdot2\cdot1 =\mathbf{24}$. This pattern applies to any number of unique items you select. For example, if you have $5$ unique objects, you can arrange them in $5\cdot4\cdot3\cdot2\cdot1 = 120$ different ways. If you instead have $11$ unique objects, there are $11\cdot 10 \ldots 2 \cdot 1 = 39 \ 916 \ 800$ different ways to arrange them in, and so on. As you may have noticed, it becomes rather tedious to write long products like $11 \cdot 10 \ldots 2 \cdot 1$. We can shorten this by simply putting an exclamation mark after the first number, so $11 \cdot 10 \ldots 2 \cdot 1$ just becomes $11!$. This is pronounced as "eleven factorial".


Exercise 1

Carla has five different flowers that she wants to plant in a row in her flowerbed. In how many ways can she plant the flowers?

This should be simple to you by now. Five different objects placed in a row can be arranged in $5! = 5 \cdot 4 \cdot 3 \cdot 2 \cdot 1 = \mathbf{120}$ unique ways. 


Exercise 2

15 students are starting a new class and their teacher is deciding on where to seat them. However, there are 20 chairs in the classroom to choose from. In how many ways can the students be seated?

The first student can choose between 20 different seats, the second student between 19 different seats, and so on until the fifteenth student who can choose between 6 different seats. There are thus $20 \cdot 19 \ldots 7 \cdot 6 = \mathbf{\dfrac{20!}{5!}}$ unique ways in which the students can be seated. Notice how we were able to rewrite $$20 \cdot 19 \ldots 7 \cdot 6 \ = \ \frac{20!}{5!}$$ By dividing with $5!$, we remove the last $5 \cdot 4 \cdot 3 \cdot 2 \cdot 1$ that we don't want in the multiplication. Keep this technique in mind. You'll see it many times again. You will also notice that we chose to present the final answer in the form $\dfrac{20!}{5!}$ instead of as a number. The reason for this is that factorials become very large very quickly. The number of ways the students can be seated is in fact so great that this number contains 17 digits! Because factorials get so large so quickly, we often prefer to keep them in factorial form if the answer is larger than 6 or 7 digits.


Exercise 3

Thomas has hung up two shelves in his living room. He will place three different potted plants on the upper shelf and five pictures of his children on the lower shelf. In how many ways could Thomas choose to place all eight items on the shelves?

There are $3! = 3 \cdot 2 \cdot 1 = 6$ different ways to place the plants on the upper shelf. For each of these 6 permutations, there are $5 = 5 \cdot 4 \cdot 3 \cdot 2 \cdot 1 = 120$ different ways to place the five pictures on the lower shelf. This means that there are $6 \cdot 120 = \mathbf{720}$ different ways to place all eight items on the shelves. 


Exercise 4

How many times greater is $101!$ than $99!$?

$101!$ is the same as $101\cdot100\cdot (99!)$. $101!$ is therefore $101\cdot100 =\mathbf{10 \ 100}$ times larger than $99!$.


When All Items Aren't Unique...

Does the number of permutations change if two objects look exactly the same? Take these three triangles as an example. 


Theoretically, we could arrange the three triangles in $3! = 6$ different ways. But of course these permutations will all look exactly the same. We just end $6$ copies of the same permutation. This is obviously not very practical, and for that reason we are usually interested only in unique permutations. Take these five objects as an example:


Since we have five objects, we can arrange them in $120$ different ways. But several of these permutations will be copies of each other. Our task is thus to find out how many copies there are for each unique permutation. We can investigate this by giving each square a number.

 

As long as we only let the square change places, we will still have the same permutation. So the question is how many ways can we arrange the $3$ squares? The answer is of course $3! = 6$. No matter where the triangle and the circle are placed, we will have three empty spaces left to choose from for square $1$, then two for square $2$ and finally one space for square $3$. Below you can see all possible copies of this permutation.



This means that there are $3! = 6$ copies of each unique permutation. The number of unique permutations of the five objects must therefore be $\frac{5!}{3!} =\mathbf{20}$. By dividing the total number of permutations with the number of copies for each permutation, we end up only counting the permutations that are unique. 

$$\text{#Unique Permutations} \ \times \ \text{#Copies Of Each Permutation} \ = \ \text{Total #Permutations}$$

$$\text{#Unique Permutations} \ = \ \frac{\text{Total #Permutations}}{\text{#Copies Of Each Permutation}}$$

This pattern applies to all numbers. For example, if you have $7$ objects consisting of a square, a triangle, a pentagon and four identical circles, you will be able to create $\frac{7!}{4!} =210$ unique permutations. Seven objects can be arranged in $7! = 5040$ ways, but in this case we end up with $4! = 24$ copies of each unique permutation. To avoid counting these copies we divide by $4!$, which gives us a total of $210$ unique permutations.



Exercise 1

How many "words" can you create by rearranging the letters in BABOON?

Six letters can be arranged in $6!$ permutations. However, the order of the two B:s and the two O:s don't matter. We therefore need to divide by $2!$ for each of them. The letters in BABOON can thus be rearranged to form $\dfrac{6!}{2! \ \cdot \ 2!} = \mathbf{180}$ words.  


Exercise 2

a) Lisa has two pennies and four nickels. If the six coins are placed in a row, how many unique permutations are there?
b) Lisa now adds three quarters to her six coins in question a). How many unique permutations are there of these nine coins?

a) Six objects can be arranged in $6!$ ways. However, because the pennies are identical it doesn't matter in which order we place them in so we need to divide by $2!$. Neither does it matter in which order we place the four nickels in, so we also need to divide by $4!$. This means that there are $\frac{6!}{2! \ \cdot \ 4!}=\mathbf{15}$ unique permutations of the six coins. 

b) Six objects can be arranged in $6!$ ways. But since we have two identical pennies, four identical dimes and three identical quarters, we need to divide by $2!$, by $4!$ and by $3!$ to avoid over-counting. This means that there are $\frac{9!}{2! \ \cdot \ 4! \ \cdot \ 3!}=\mathbf{1260}$ unique permutations of the nine coins.


Choosing Multiple Objects from a Larger Set

Sara is packing for a trip to Spain and wants to bring along some books for reading. She has nine books to choose from and she decides to bring along three of them. 


Exercise 1

How many options does Sara have when she chooses her first book? How many for the second book and the third book?

Sara has 9 options when choosing her first book, 8 options for her second book and 7 options for her third book. 


Exercise 2

How many unique combinations of books could she choose? (Just to clarify, for two choices to be unique they must consist of different combinations of books. We do not care in which order they were chosen).

Can we just multiply the number of options that Sara has for choosing each book? If not, how can we avoid overcounting?

If we multiply 9, 8 and 7, the product $9\cdot8\cdot7 = 504$ will include every possible way in which Sara can select three of her nine books. One of these $504$ ways is that she first chooses book $A$, then book $B$ and lastly book $C$. Another way is that she first chooses book $C$, then book $A$ and lastly book $B$. As you can see, we have a problem here. $\{A, B, C\}$ and $\{C, A, B\}$ are not two unique sets of books. They are two different permutations of the same set. How can we avoid counting the same set more than once? 

The same set of three books can be chosen in $3! = 6$ different ways. For example, if I chose the unique set $\{A, B, C\}$, I have three options for the first book, two options for the second and one option for the third book which is $3 \cdot 2 \cdot 1 = 3!$. Among the total $9\cdot8\cdot7 = 504$ ways to choose three books, there will thus be $3!=6$ copies of each unique book set. The number unique books sets that Sara can choose is therefore $\frac{9 \ \cdot \ 8 \ \cdot \ 7}{3!} =\mathbf{84}$.

This principle applies to any number of objects we choose. Had Sara chosen five books instead of three, she could have picked $\frac{9 \ \cdot \ 8 \ \cdot \ 7 \ \cdot \ 6 \ \cdot \ 5}{5!} =126$ unique book sets. 


Exercise 3

Ten neighbours meet for dinner and everyone greets by shaking hands once with everyone invited. How many handshakes will there be in total?

Each of the ten neighbours shakes hands with nine other people. That neighbour $A$ shakes hands with neighbour $B$ is the same as that $B$ shakes hands with $A$ so in order not to overestimate we have to divide the number of greetings by 2. In total, there will be $\frac{10 \ \cdot \ 9}{2} =\mathbf{45}$ handshakes.

This question can actually be rephrased to "How many pairs of two people could we choose from a group of ten people?". Every pair will be equal to one handshake. Phrased this way, it's obvious that the answer is $\frac{10 \ \cdot \ 9}{2} =45$.


Exercise 4

Sara also packs five T-shirts, four skirts and two sneakers for her trip. If she had seven different t-shirts, six different skirts and three different sneakers to choose from, how many unique sets of clothes could Sara have packed? 

Sara could have chosen $\frac{7 \cdot 6 \cdot 5 \cdot 4 \cdot 3}{5!}=21$ sets of T-shirts, $\frac{6 \cdot 5 \cdot 4 \cdot 3}{4!}=15$ sets of skirts and $\frac{3 \cdot 2}{2!}=3$ sets of sneakers. Sara could therefore have chosen a total of $21 \cdot 15 \cdot 3=\mathbf{945}$ unique sets of clothes. 


Exercise 5

a) How many sets of 20 objects could you choose from a set of 100 different objects?

b) How many sets of $m$ objects could you choose from a set of $n$ different objects, where $m≤n$?

a) We can select 20 objects from a set of 100 different objects in

$$\frac{100 \ \cdot \ 99 \ \ldots \ \cdot \ 82 \ \cdot \ 81}{20!}$$

different ways. However, we can express this in more simplified way. The numerator $100 \ \cdot \ 99 \ \cdot \ldots \ \cdot \ 82 \ \cdot \ 81$ can be rewritten as $\frac{100!}{80!}$. By dividing by $80!$, we remove the last 80 factors that we don't want in the product. We thus get:

$$\dfrac{100 \ \cdot \ 99 \ \cdot \ \ldots \ \cdot \ 82 \ \cdot \ 81}{20!} \ \ \ = \ \ \frac{\dfrac{100!}{80!}}{20!} \ \ = \ \ \mathbf{\frac{100!}{80! \ \cdot \ 20!}}$$

b) We can select $m$ objects from a set of $n$ different objects in

$$\frac{n \ \cdot \ (n - 1) \ \cdot \ \ldots \ \cdot \ (n - m + 2) \ \cdot \ (n - m + 1)}{m!}$$

different ways. Using the same principle as in question a), we can simplify this to:

$$\frac{n \ \cdot \ (n-1) \ \cdot \ \ldots \ \cdot \ (n-m+2) \ \cdot \ (n-m+1)}{m!} \ \ \ \ = \ \ \frac{\dfrac{n!}{(n-m)!}}{m!} \ \ = \ \ \dfrac{n!}{(n - m)! \ \cdot\ m!}$$

This expression is so common in combinatorics that it has been given its own special expression:

$$\dfrac{n!}{(n - m)! \ \cdot\ m!} \ = \ \binom{n}{m}$$

The symbol $\displaystyle{\binom{n}{m}}$ is pronounced as "$n$ choose $m$" because it represents the number of ways that $m$ objects can be selected from a set of $n$ different objects. Sometimes you will also see this expressed as $C_{m}(n)$, but $\displaystyle{\binom{n}{m}}$ is the most common of the two notations. The answer to question a) could thus also have been written as: 

$$\binom{100}{20} \ = \ C_{20}(100)$$


Exercise 6

Solve the questions below. State your answer by using the notations $k!$ and $\displaystyle{\binom{n}{m}}$. 

a) In a class there are 25 students. The teacher will choose three students as class representatives. In how many ways is this possible?

b) Gabriel is at a pinchos restaurant that offers 18 pinchos on its menu. He will choose four different pinchos and he has already decided that the shrimp salad will be one of them. How many choices of pinchos could Gabriel choose? 

c) Twenty bikers are participating in a long-distance cycling race. The three best participants will be honored with a gold, silver and bronze medal. How many different outcomes could the race have?

d) A small village of 30 people will choose six villagers among themselves to form a governing council. They council will consist of two senior and four junior members. How many unique councils could be formed? 

e) Simon wants to decorate his living room with three potted plants. He has five plants and six differently colored pots to choose from. How many combinations of plants and flower pots could he choose? 

a) The teacher can select $\mathbf{\displaystyle{\binom{25}{3}}}$ sets of three students as class representatives. 

b) Because Gabriel has already chosen one of his four pinchos, he is actually only choosing three pinchos from a selection of 17 pinchos. Gabriel can therefore choose among $\mathbf{\displaystyle{\binom{17}{3}}}$ servings. 

c) In this scenario, the order in which the three best participants arrive matters. There are thus
$$\mathbf{20 \cdot 19 \cdot 18 = \dfrac{20!}{17!}}$$
possible outcomes in the race. Because the order matters, we don't divide by $3!$ as we otherwise do. 

d) There are $\displaystyle{\binom{30}{2}}$ pairs of senior members that could be chosen. Once the senior members are chosen, there are only 28 villagers left from which to choose the four junior members. There are thus
$$\mathbf{\displaystyle{\binom{30}{2}} \ \cdot \ \displaystyle{\binom{28}{4}}}$$
unique councils that could be formed. 

e) Simon can choose $\displaystyle{\binom{5}{3}}$ sets of plants. He may then choose among six pots for the first plant, among five pots for the second plant and among four pots for the third plant. Because the same three plants and the same three pots can be combined in unique ways, the order in which the pots are chosen matters. Simon thus has
$$\mathbf{\binom{5}{3} \ \cdot \ (6 \cdot 5 \cdot 4) \ = \  \binom{5}{3} \ \cdot \ \frac{6!}{3!}}$$

possible combinations of plants and pots to choose from. 


Solving the Mystery!

Let us now return to the original question we faced at the start of this lesson. If both my sister and I wanted to choose an ice cream cone with three out of six different flavours, and I wanted at least one ball with the same flavour as my sister, how many ice creams could we have chosen? 


Exercise 1

How many ice creams could my sister have chosen? 

My sister could have chosen $\displaystyle{\binom{6}{3}}=\dfrac{6 \cdot \ 5 \ \cdot 4}{3!}=\mathbf{20}$ different ice creams. 


Exercise 2

Once my sister has chosen her ice cream, how many ice creams could I choose if at least one of my flavours has to be the same as? How many different ice creams could my sister and and I then have chosen together? 

No matter which ice cream my sister chooses, there is going to be exactly one ice cream that doesn't have any similar flavours. For example, if my sister chooses the ice creams with flavours $\{1,2,3\}$, I can pick any combination of flavours except $\{4,5,6\}$. This means that I will always be able to pick $20-1=19$ possible ice creams. My sister and I can therefore choose $20 \cdot 19 = \mathbf{380}$ ice creams together. 


Splitting it up into Different Cases

A snack bowl contains six brightly colored M&Ms: 1 red, 1 green, 1 yellow, 1 brown and 2 blue. Petra allows her three-year-old Ralph son to choose three M&Ms from the bowl. How many different combinations of M&Ms could he choose? 

This problem can't be solved by simply dividing $6!$ with $3!$. That method is based on the fact that each set of three objects can be chosen in exactly $3!$ different ways, and thus will give rise to $6$ copies of each unique set. But what if Ralph chooses the red and the two blue M&Ms? How many copies are there of that set? The answer is not $3! = 6$, because it doesn't matter in which order the blue M&Ms were chosen. We actually only have $\frac{3!}{2!} = 3$ copies of that set. Our method of dividing by $3!$ only works for combinations of M&Ms where all colors are different. To solve this problem, we therefore have to divide it into different cases.

(1) All three M&Ms have different colors
In this case, Ralph may not pick two blue M&Ms. But if we remove one of the blue M&MS, he is free to choose any combination of the remaining chocolates that we likes. Ralph can therefore choose $\displaystyle{\binom{5}{3}}=10$ different combinations of M&Ms in this case. 

(2) All three M&Ms don't have different colors
In this case, Ralph must pick both blue M&Ms. Once he has selected these, he only has 4 different M&Ms left to choose from for his third chocolate: red, green, yellow or brown. Ralph can therefore choose 4 different combinations of M&Ms in this case. 

In total, Ralph can thus choose $10 + 4 = \mathbf{14}$ unique combinations of three M&Ms.

Sometimes we can't solve a problem with only one single calculation. This happens when we have to make several choices to make, but not all combinations of choices can be selected in the same number of ways. For example, if Ralph choose three M&Ms that all were different, we could have selected this set in $3!=6$ different ways. But if he instead chose both of the blue M&Ms, he could only have selected this set in $\frac{3!}{2!}=3$ different ways. The answer to the first case was $\displaystyle{\binom{5}{3}}=10$ ​​because Ralph could select 3 objects from a set of 5 unique ones. The answer to the second case, however, was $\displaystyle{\binom{4}{1}}=4$ because Ralph could select $1$ objects from a set of $4$ unique ones. There is no connection whatsoever between these two scenarios. It is therefore much easier to divide them into different cases, calculate them separately and then add the results up at the end.


Exercise 1

Samuel has three jackets and four hats to choose from when he goes outdoors. How many combinations of jackets and hats could he choose?

Samuel can choose his outfit in $3 \cdot 4 = \mathbf{12}$ different ways. The number of hats he can choose doesn't change depending on which jacket he picks. Therefore, we can just multiply the number of jackets and hats to determine the total number of combinations.


Exercise 2

If Samuel doesn't want to wear his blue hat together with his brown jacket or his black jacket, how many combinations of jackets and hats could he choose then?

In this problem, Samuel's choice of hat now impacts the number of jackets he has available. There are fewer ways that Samuel can choose an outfit that includes his blue hat compared to outfits that doesn't include his blue hat. We should therefore divide the problem into different cases. 

(1) The hat Samuel chooses is blue

This gives Samuel one choice for his hat. Since he now won't choose either the brown or the black jacket, he only has one jacket left to choose from. Samuel therefore has only $1\cdot1 = 1$ possible outfit in this case.

(2) The hat Samuel chooses is not blue

This gives Samuel three hats to choose from and he may now choose any of his three jackets. Samuel therefore has  $3 \cdot 3 = 9$ possible outfits in this case.

In total, Samuel can thus combine his hats and jackets in $1 + 9 =\mathbf{10}$ different ways. 

NOTE! When you divide a task into different cases, it is very important that your cases really cover all possible alternatives and that there also is no overlap between the cases. Otherwise, you will either miss counting some outcomes or count some outcomes more than once. This is sometimes called the MECE Principle: Mutually Exclusive and Collectively Exhaustive. Mutually exclusive means that two cases can't happen at the same time, so there is no overlap. Collectively exhaustive means that our together cases cover all possible outcomes. 


Exercise 3

How many positive integers between 100 and 299 contain exactly two similar digits? (We include both 100 and 299 in our counting). 

The hundreds digit must be either 1 or 2. The integers that has the hundreds digit as one of their two similar digits, however, can be chosen in a different number of ways compared to the integers that doesn't have the hundreds digit as one of the two similar digits. We must therefore split up the problem into the two different cases:

(1) The hundreds digit is one of the two similar digits
We have two choices for the hundred digit: 1 or 2. One of the two remaining digits must be the same as the hundreds digit, but we can choose if this digit should be either in the tens place or the units place. The last digit we can choose freely from the ten existing digits. This case thus gives us $2\cdot2\cdot10 = 40$ outcomes.

(2) The hundreds digit is not one of the two similar digits
Again, we have two choices for the hundreds digit: 1 or 2. The tens and units digits must be the same, but we have nine different choices for which digit it should be. (We can choose any of the ten digits except the digit we chose for the hundreds digit). This case thus gives us $2 \cdot 9 = 18$ outcomes.

In total, there are thus $40 + 18 =\mathbf{58}$ positive integers between 100 and 299 that have exactly two similar digits.


Exercise 4

The students Hugo, Wilhelmina and Rachel together have three $1 bills. In how many ways could they split the three bills between each other?

This task problem can be divided into the following three cases:

(1) Everyone have at least one bill  (1,1,1)
This can only be done in 1 way: all children have one bill each.

(2) One student has no bills  (0,1,2)
One of the other two students thus has two bills and the third student has one bill. Because everyone has a different number of bills, this could be done in $3! = 6$ different ways.

(3) Two students have no bills  (0,0,3)
In this case, one of the children has all three bills. We can choose which child gets the three bills in 3 different ways.

Hugo, Wilhelmina and Rachel can thus divide the three bills between themselves in $1 + 6 + 3 = \mathbf{10}$ different ways.


Counting the Wrong Thing

How many four-digit numbers have at least one even digit?

This question isn't as easy to answer as we might think. There are actually as many as five different categories of four-digit integers that we have to consider: 

(1) Four-digit integers with 0 even digits
(2) Four-digit integers with 1 even digit
(3) Four-digit integers with 2 even digits
(4) Four-digit integers with 3 even digits
(5) Four-digit integers with 4 even digits

The number of four-digit integers with at least one even digit is equal to the sum of cases: (2) + (3) + (4) + (5). Each of these cases have to be calculated separately since the number of options differs in each case. But this require a lot of work. 


Exercise 1

Can you find an easier way to determine the sum of cases (2) + (3) + (4) + (5) that doesn't require us to calculate each case?

Every four-digit number can be sorted into one of the five categories. The sum of all five cases therefore has to equal the total number of four-digit integers. But this means that we can find the answer by instead determining case (1): Four-digit integers no even digits, and subtracting that from the total! 

$$(1) + (2) + (3) + (4) + (5) \ = \ \text{Total Four-Digit Integers}$$
$$\text{Total Four-Digit Integers} - (1) \ = \ (2) + (3) + (4) + (5)$$

Let's first determine the total. The first digit in a number can't be 0, so we have nine options for the first digit but ten options for the other three. So in total there are $9 \cdot 10 \cdot 10  \cdot 10 = 9000$ four-digit integers. Now let's determine the number of four-digit integers with no even digits. In this case we have five options to choose from (1,3,5,7,9) for all four digits in the number so there $5 \cdot 5 \cdot 5 \cdot 5 = 625$ four-digit integers with no even digits. The number of four-digit integers with at least one even digit is therefore $9000-625=\pmb{8375}$.

When a problem can be split up into different cases, we have two methods to choose from. We can use either the direct addition method and count the things we want. Or we can use the indirect subtraction method and count the things we don't want and subtract that from the total. Be prepared to use whichever method that will require the least amount of work. When a problem includes phrases such as "at least", "at most" or "no more than", this is a clue that we need to determine the sum of several different cases. In these scenarios, the subtraction method is almost always going to be the fastest. 


Exercise 2

While on vacation in Japan, Sofia visits the town's local market. One of the stands offers twelve different teas: three red, four green and five black. In how many ways can Sofia choose four different teas if she wants at least one of them to be green? 

This problem can be divided into five different cases. Sofia can choose: 

(1) 0 green teas
(2) 1 green tea
(3) 2 green teas
(4) 3 green teas
(5) 4 green teas

We want to calculate the sum of cases (2), (3), (4) and (5). We can either use the addition method and calculate all four cases separately. Or we calculate case (1), that none of the teas are red, and subtract it from the total. The subtraction method obviously requires the least amount of work.

Sofia can choose $\displaystyle{\binom{12}{3}}=\dfrac{12 \ \cdot \ 11 \ \cdot \ 10}{3!} = 220$ unique combinations of four teas in total. If no tea may be green, she has eight teas left to choose from. This can be done in $\displaystyle{\binom{8}{3}}=\dfrac{8 \ \cdot \ 7 \ \cdot \ 6}{3!} = 56$ different ways. Sofia can thus choose $220 - 56 =\pmb{164}$ combinations of teas so that at least one of them is green.


Exercise 3

The art teacher Patrick has a large pack of colored pencils. The pencils are either red, green, blue, pink or brown. In how many ways could Patrick:

a) give three students one pencil each?

b) give three students one pencil each so that no student has the same color?

c) give three green pencils to ten students so that no student has more than one pencil?

d) give three differently colored pencils to ten students so that no student has more than one pencil?

e) give three pink pencils to three students? (The students don't need to have to have the same number of pencils). 

f) give three pencils to three students so that no more than two pencils are red or brown? (The students don't need to have to have the same number of pencils). 

a) For each student, Patrick can choose between five different colors. He can thus give out pencils in $5^3 =\pmb{125}$ different ways.


b) Patrick can choose among five colors for the first student, four colors for the second student and three colors for the third student. This can be done in $5 \cdot 4 \cdot 3 =\pmb{60}$ different ways.

c) Patrick will choose three students from a group of ten to which he will give one green pencil each. This can be done in $\displaystyle{\binom{10}{3}} = \dfrac{10 \ \cdot \ 9 \ \cdot \ 7}{3!} =\pmb{120}$ different ways.

d) This is the same problem as c) but the difference is now that the color of the pencils may vary. For each of the $120$ possible distributions of pencils in question c), the pencils could have $5 \cdot 4 \cdot 3 = 120$ different color combinations. Patrick can thus give out the three pens in $120 \cdot 120 =\pmb{14 \ 400}$ different ways.

e) This problem can be divided into three different cases:

(1) All students have one pencil  (1,1,1)
In this case, there is only one way in which the pencils can be distributed: everyone gets one pencil each.

(2) One student has no pencil  (0,1,2)
In this case, a student has two pencils, a student has a pen and a student does not get a pen. This can be done in $3! = 6$ different ways.

(3) Two students have no pencil  (0,0,3)
This means that one student has all three pencils while the others have no pencil. This can be done in $\frac{3}{2!} = 3$ different ways.

Patrick can thus give three pink pencils to three students in $1 + 6 + 3 =\pmb{10}$ different ways.

f) This is almost the same task as e) but with the difference that the color of the pencils may differ. We can thus divide the problem into the following four cases:

(1) 0 pencils are red or brown
(2) 1 pencil is red or brown
(3) 2 are red or brown
(4) 3 pencils are red or brown

We want at most two pencils to be red or brown, which is the sum of cases (1), (2) and (3). The easiest way to determine this is to use the subtraction method. We simply determine the total number ot outcomes and subtract the number of pencils in case (4). There are $5^3 = 125$ different ways in total that the three pencils could be colored. (Because the pencils will be given to three different students, the order in which the pencils are chosen matters). If all three pencils must be either red or brown, there are $2^3 = 8$ ways in which the pencils could be chosen.

In question e), we determined that Patrick could give three same-colored pencils to three students in 10 different ways. For each of these 10 distributions, the pencils can now have $125 - 8 = 117$ unique color combinations. In total, there are thus $10 ​​\cdot 117 =\pmb{1170}$ different ways that Patrick can give three pencils to three students with at most two pencils being either red or brown. 


A Common Trap: Flips and Rotations

So far we have only considered objects that are placed in a row. But sometimes we will encounter problems where the objects instead are arranged in a circle. This is a big difference. Contrary to a row, a circle can be rotated without leading to a new permutation.

If five people in a circle all jump one step to the right, the order is still the same. If five people had instead been placed in a row, each jump to the right (the fifth person moving to the front of the row) would have formed a new permutation.


Exercise 1

The five members of the Council of the Elders are seated at a round table. How many ways could they be seated? We consider two seating arrangements to be the same if one is a rotation of the other. 

Had the five council members been seated in a row there would have been $5!=120$ different seating arrangements. But in a circle, the council members can rotate their positions five times while still being seated in the same permutation. This means that there will only be $\dfrac{120}{5}=\pmb{24}$ unique ways in which the council can be seated. 

This pattern holds true generally. If we have $n$ objects arranged in a circle we can rotate the circle $n$ times. The number of unique permutations is therefore $\dfrac{n!}{n} = (n-1)!$. 

Another way to think about this is to fixate one of the objects. Because that object has to be in a certain place we can no longer rotate the circle. Now we have $(n-1)!$ objects left to arrange, and this time it will be like we arrange them in a row so the number of permutations again is $(n-1)!$. 


Exercise 2

The Council of Elders are taking their seats again. But this time we will only consider two seating arrangement to be the same if everyone is seated next to the same two people. How many unique ways can the elders be seated then? 

Let's fixate the position of person $A$. The other four elders can then be seated in $4!=24$ different ways. However, it's now possible to "flip" or "mirror" the entire seating arrangement with respect to person $A$ and still have everyone seated to the same two people. Consider the example below.



This means that there will be two copies of every unique seating arrangement, where one is the mirrored version of the other. The elders can therefore be seated in $\dfrac{24}{2}=\pmb{12}$ unique ways. 

Whenever we only care which neighbours each object has, we always need to divide by $2$ to avoid counting the mirrored versions. 


Exercise 3

a) Three different keys are placed around a keychain. In how many unique ways could the keys be placed? 

b) A fourth key is now added to the chain. In how many unique ways can the keys be placed now? 

a) Keychains are circles in a 3D world. They can be rotated and also flipped upside-down with the keys still being in the same order. This means that there is only $\dfrac{3!}{3 \ \cdot \ 2}=\pmb{1}$ way in which three keys can be placed. This may seem counter-intuitive at first. After all, we would expect there to be more than just one keychain when three keys at our disposal. But it make sense if you think about how many different "neighbours" that each key could have. No matter how we place the keys, $A$ will always be between $B$ and $C$, $B$ will always be between $A$ and $C$, and $C$ will always be between $A$ and $B$. Viewed this way, it's obvious that there exists only one unique keychain with three keys. 

b) The fourth key can be inserted in three places - between $A$ and $B$, between $A$ and $C$, or between $B$ and $C$ - so there are $\pmb{3}$ unique keychains with four keys. We could also have solved this in the traditional way by dividing $4!$ first by $4$ (discarding rotations) and secondly by $2$ (discarding mirrorings) which gives us the same answer $\dfrac{4!}{4 \ \cdot \ 2}=\pmb{3}$. 


Exercise 4

The king visits his royal goldsmith and makes the following request:
"I want you to forge me three jeweled rings. The jewels should be placed evenly around each ring. I require one gold ring with five jewels, one silver ring with four jewels and one bronze ring with three jewels."
The goldsmith has $15$ different jewels in his safe to choose from. How many unique sets of rings could he present to the king?

The king could choose the five jewels for the gold ring in $\displaystyle{\binom{15}{5}}=\dfrac{14 \ \cdot \ 13 \ \cdot \ 12 \ \cdot \ 11 \  \cdot \ 10}{5!} = 364$ ways. Since he now has $9$ jewels left, he can choose the jewels for the silver ring in $\displaystyle{\binom{9}{4}}=\dfrac{9 \ \cdot \ 8 \ \cdot \ 7 \ \cdot \ 6}{4!} = 126$ ways. The goldsmith now has $5$ jewels left for the bronze ring so he can choose which three jewels to use for this ring in $\displaystyle{\binom{5}{3}}=\dfrac{5 \ \cdot \ 4 \ \cdot \ 3}{3!} = 10$ ways. Now we need to consider the number of ways in which the jewels could be fastened around the three rings. 

A ring is a circle in 3D. It can therefore be rotated and flipped around while sporting the same permutation. We therefore need to divide by the number of "row-permutations" by the number of jewels in each ring to avoid overcounting the rotations. We also need to divide by $2$ for each ring to avoid counting the same ring when its flipped over. The number of ways in which the jewels can be placed around the three circles are thus as follows:

The gold ring:  $\dfrac{5!}{5 \ \cdot \ 2} = 12$ ways
The silver ring:  $\dfrac{4!}{4 \ \cdot \ 2} = 3$ ways 
The bronze ring:  $\dfrac{3!}{3 \ \cdot \ 2} = 1$ way

The goldsmith can thus present his king with $364 \cdot 126 \cdot 10 \cdot 12 \cdot 3 \cdot 1 = \pmb{16 \ 511 \ 040}$ unique sets of rings. 


Problems to Solve

Exercise 1

The 6 students in the student council want to convene all the school's students to a meeting in the auditorium. Each of the student council members calls 6 students, who in turn calls 6 students each and these eventually call 4 students each. How many students know about the meeting if none of the students has received more than one call?

The 6 student council members call 6 students each, so in the first tier there are $6\cdot6=36$ students.

Each student in the first tier then calls on 6 other students each, so in the second tier there are $36\cdot6=216$ students.

Each student in the second tier then calls on 6 other students each, so in the third tier there are $216\cdot4=864$ students. 

Since no student have received more than one call there are in total $6+36+216+864=\mathbf{1122}$ students who know about the meeting.


Exercise 2

On a platter there are eight different kinds of cookies. How many sets of three cookies could you choose if you may only take one of each kind?

We could choose $\displaystyle{\binom{8}{3}}=\dfrac{8 \ \cdot \ 7 \ \cdot \ 6}{3!} =\pmb{56}$ sets of three different cookies.


Exercise 3

A good word consists only of the letters P, Y, T, H and Q. In addition, P must not be followed directly by Y, Y must not be followed directly by T, T must not be followed directly by H, H may not followed directly by Q and Q must not be followed directly by P. How many good words of length five are there? (The same letter may be used more than once, for example PPPPP). 

We have five options for the first letter. For the second letter there are only four options, as there is always one letter that must not be followed directly by another. For the same reason, we also have four options to choose from for the third, the fourth and the fifth letter. All in all, there are $5\cdot4\cdot4\cdot4\cdot4 =\pmb{1280}$ good words.


Exercise 4

A yoghurt shop offers six flavours and three toppings. If a customer wants three flavours and two toppings, how many combinations could be chosen?

The customer can choose $displaystyle{\binom{6}{3}} = \dfrac{6 \ \cdot \ 5 \ \cdot \ 4}{3!} = 20$ combinations of flavours and $displaystyle{\binom{3}{2}} = \dfrac{3 \ \cdot \ 2}{2!} = 3$ combinations of toppings. There are thus possible $20 \cdot 3 =\pmb{60}$ combinations with three flavours and two toppings that could be chosen. 


Exercise 5

In how many ways can five books be arranged on a shelf if books $A$ and $B$ must be next to each other?

Books $A$ and $B$ can be placed in four different ways: places (1,2), (2,3), (3,4) or (4,5). For each of these placements, we can also choose if the two books should come in order $(A,B)$ or $(B,A)$. The last three books can now be placed in $3! = 6$ different ways. In total, we can arrange the five books in $4 \cdot 2 \cdot 6 =\pmb{48}$ different ways.


Exercise 6

Claudia has twelve dollar bills. Each bill is either a \$5 or a \$10 bill. By combining these, she can get exactly 17 different sums (sum $\neq 0$). How many \$10 bills does Claudia have?

Solution 1
Claudia must have at least one \$5 bill as she can get a maximum of $12$ different sums if she has only twelve \$10 bills. The bills can be combined to all sums divisible by $5$ beginning with $5,10,\dots$. Since Claudia can form $17$ different sums, the $17$th sum must be $17 \cdot 5 = 85$.

If all the $12$ bills had been \$5 bills, the highest attainable sum would be $5 \cdot 12 = 60$. For each \$10 bill that is swapped for a \$5 bill, the sum of all bills increases by five. To get from $60$ to $85$, Claudia therefore needs to swap $\frac{85-60}{5}=5$ number of \$5 bills for \$10 bills. 

The number of \$10 bills that Claudia has is therefore $\pmb{5}$. 

Solution 2
Claudia must have at least one \$5 bill as she can get a maximum of $12$ different sums if she has only twelve \$10 bills. Since she has at least one \$5 she can get any sum that is a multiple of $5$, that is, $5, 10, 15, 20$… etc, until she reaches her maximum limit. In order for her to achieve exactly $17$ different sums, the largest number she can create must be $17 \cdot 5 = 85$. Let's say that Claudia has $x$ \$5 bills and $y$ \$10 bills. This gives us:

$$ x + y = 12$$

$$5x + 10y = 85 $$

which has the solution $(x, y) = (7, 5)$. Claudia thus has $\pmb{5}$ \$10 bills.


Exercise 7

Six railway carts, P, Y, T, H, Q and U, are to be put together in such a way that P must come before Y. In how many ways is this possible?

Once we have decided the placements for carts P and Y, the remaining four carts can always be placed in $4! = 24$ ways. If we can determine the number of possible placements of P and Y, we only need to multiply that result by $24$ to get the total number of ways the six carts could be assembled.

If P is in the first place, there are five places left for cart Y. If P is in the second place, there are four places left for cart Y, etc. By continuing this procedure we conclude that carts P and Y can be arranged in $5 + 4 + 3 + 2 + 1 = 15$ different ways. Thus, there are $15 \cdot 24 =\pmb{360}$ possible ways to assemble all the six the railway carts.


Exercise 8

How many five-digit integers have at least two odd digits?

This problem can be divided into the following six cases:

(1) Five-digit integers with 0 odd digits

(2) Five-digit integers with 1 odd digit

(3) Five-digit integers with 2 odd digits

(4) Five-digit integers with 3 odd digits

(5) Five-digit integers with 4 odd digits

(6) Five-digit integers with 5 odd digits

The number of five-digit integers with at least two odd digits is the sum of cases (3), (4), (5) and (6). This easiest way to determine this is through the subtraction method. We determine the sum of cases (1) and (2) and subtract it from the total number of five-digit integers. There are $4\cdot5\cdot5\cdot5\cdot5 = 2500$ five-digit numbers with no odd digits. (The first digit can't be $0$ so we only have four even digits to choose from for the first digit instead of five). We will now determine the number of five-digit integers with exactly one odd digit. Depending on whether the first digit is odd or even, the number of options will differ. We therefore need to divide this case into the following two sub-cases:

(2.1) The first digit is odd
There are five options for the first digit. There are also five options for each of the remaining four digits, which all must be even. This case thus gives us $5\cdot5\cdot5\cdot5\cdot5 = 5^5 = 3125$ possible integers.

(2.2) The first digit is not odd
There are four options for the first digit: $2,4,6$ or $8$. We have five digits to choose from for the odd digit, and the odd digit can also be placed in four different places. There are five options each for the remaining three digits, which all must be even. This case thus gives us $4\cdot (5 \cdot 4) \cdot 5 \cdot 5 \cdot 5 = 10 \ 000$ possible integers.

There are thus $3125 + 10,000 = 13 125$ five-digit numbers with exactly one odd number. The total number of five-digit integers is $9 \cdot 10 \cdot 10 \cdot 10 \cdot1 0 = 9 \cdot1 0^4 = 90 \ 000$. All in all, there are $90 \ 000 - 2500 - 13 \ 125 =\pmb{74 \ 375}$ five-digit numbers that have at least two odd digits.


Exercise 9

Fewer than $50$ people are invited to a party. Each person shakes hands with all the other guests. What is the greatest number of guests that could attend the party if there were an odd number of handshakes in total?

Let the number of guests at the party be $n$. Each guest shakes hands with $(n-1)$ other guests. But the order of the handshake doesn't matter ($A$ shaking hands with $B$ is the same $B$ shaking hands with $A$) we need to divide by $2$. The total number of handshakes is then $\frac{n(n - 1)}{2}$. One of $n$ or $(n - 1)$ must be odd. For the number of handshakes $\frac{n(n - 1)}{2}$ to be odd, either $n$ or $(n - 1)$ must be divisible by $2$ only once. The greatest integer less than $50$ which is only divisible by $2$ once is $46$. The greatest number of guests possible is thus $47$ which yields a total of $\frac{47 \ \cdot \ 46}{2} =\pmb{1081}$ handshakes.


Exercise 10

Christian will exchange his bank card's four-digit PIN code. He previously had the code $\pmb{2 \ 0 \ 1 \ 7}$. What is greatest: the number of codes that include at least one of these digits, or the number of codes that don't include any of these digits?

Let us first determine the number of codes that don't include any of the digits $2, 0, 1, 7$. This means that we have $6$ options $(3,4,5,6,8,9)$ for each of the four digits digits, so the number of codes that don't include any of the digits $2,0,1,7$ is $6^4 = 1296$. The number of codes with at least one of the digits $2, 0, 1, 7$ is the same as the total number of codes minus the number of codes that don't include any of the digits $2, 0, 1 , 7$. The total number of codes is $10^4 = 10 \ 000$ and we already know that the number of codes that no digits in common with Christian's code is $1296$. This means that there are $10,000 - 1296 =\pmb{8704}$ codes that include at least one of the digits $2,0,1,7$, so this is the greater number. 


Exercise 11

Four couples (each consisting of one man and one lady) are to eat dinner at a circular table. They are not allowed to sit next to a person of the same sex or next to their partner. Denote the guests with $A, a, B, b, C, c, D, d$ where the capital letter stands for the ladies. In how many unique ways can they be seated? Two seating arrangements are considered to be the same if everyone has the same two people seated next to them.

First off, we focus only on the ways the females can be arranged in aspect to one another. This is equivalent to calculating the number of different ways to arrange four females in a circle. We fix one female, say $A$, and we can see that there are $3$ different pairs of neighbours $A$ can have: $(B,C), (C,D)$ and $(B,D)$. 

Now we notice that male $a$ only can be positioned in two ways, given a configurations of females. When we choose a place for the $a$-male, the other positions are automatically determined. Thus, there are $3 \cdot 2 = \pmb{6}$ unique ways for the guests to be seated. These seating arrangements are:

$$–AcBdCaDb– \ \ \ \ \ –AdBaCbDc– \ \ \ \ \ –AdBcDaCb–$$
$$–AcBaDbCd– \ \ \ \ \ –AdCaBcDb– \ \ \ \ \ –AbCdBcD–$$


Exercise 12

In Geometry Land, all children have toys that meet the following criteria:

  • They have one of three shapes (cube, sphere or tetrahedron).
  • They consist of one of four materials (plastic, wood, rubber or china)
  • They have one of five sizes (XL, L, M, S or XS)
  • They have one of six colors (white, black, yellow, green, red or blue.

All possible combinations are represented and all children have one toy of each kind.

a) How many different toys does each child have?

b) How many toys are different from a black XL plastic cube in at least two ways?

a) For each toy we can choose between $3$ shapes, $4$ materials, $5$ sizes and $6$ colors. The total number of possible toys is thus $3 \cdot 4 \cdot 5 \cdot 6 = \pmb{360}$.

b) All toys can be sorted into one of the following five categories:

(1) Toys that differ from a black, XL, plastic cube in $\pmb{0}$ ways
(2) Toys that differ from a black, XL, plastic cube in $\pmb{1}$ way
(3) Toys that differ from a black, XL, plastic cube in $\pmb{2}$ ways
(4) Toys that differ from a black, XL, plastic cube in $\pmb{3}$ ways
(5) Toys that differ from a black, XL, plastic cube in $\pmb{4}$ ways

The number of toys that differ from a black, XL, plastic cube in at least two ways is the sum of cases (3), (4) and (5). This easiest way to determine this is through the subtraction method. We determine the sum of cases (1) and (2) and subtract it from the total number of toys. 

(1) Toys different from a black, XL, plastic cube in $\pmb{0}$ways
There is only $1$ toys that are different from a black, XL, plastic cube in $0$ ways: that toy itself.

(2) Toys other than a black, XL, plastic cube in $\pmb{1}$ manner.
A toy can be different in either shape, material, size or color. If the toy is different in shape, there are $2$ options to choose from (sphere or tetrahedron). If the toy is different in material, there are $3$ options to choose from (wood, rubber or china). If the toy is different in size, there are $4$ options to choose from (L, M, S or XS). Last but not least, if the toy is different in color, there are $5$ options to choose from (white, yellow, green, red or blue). So there are $2 + 3 + 4 + 5 = 14$ toys that are different from a black, XL, plastic cube in exactly $1$ way.

This means that there are $360 - 14 - 1 =\pmb{345}$ toys that are different from a black, XL, plastic cube in at least two ways.