## Problems involving both permutations and combinations

On this lesson, we will focus on problems for all the past topics in combinatorics (meaning all this chapter in our statistics course), with an emphasis on both combinations and permutations. and so, we will just provide a little review in the first section (so you can have the proper formulas available to you) and then we will jump directly into example problems for you to practice.

#### Permutations and commutations

Remember that permutations are the different arrangements in which items from a list can be positioned side by side, thus paying attention in the order in which they are positioned; while combinations are the ways in which items from a set can be selected, meaning the combination of a particular quantity of objects from the whole set, no matter in which order they get arranged later. So, permutations and combinations have as a main difference, that permutations pays attention to the order of the items, while combinations do not.

The formula for permutations, also called the formula to calculate the number of arrangements of r items taken from a set of n distinct items (where the order in which the items are arranged matters), is:

$\quad$ Where:

$\quad _{n}P_{r}$ = Permutations of $r$ items from a set of $n$ items

$\quad n$ = number of total items in a set

$\quad r$ = items being arranged

Remember that when all of the items in a set are used in the process of finding the total amount of possible arrangements (when you have the same amount of items as the amount of positions in which you will arrange them), the permutations formula simplifies and is equal to just the factorial of the number of the total items in the list.

Now, looking into combinations, the formula for combinations goes as follows:

$\quad$ Where:

$\quad _{n}C_{r}$ = Combinations of $r$ items from a set of $n$ distinct items

$\quad n$ = number of total distinct items in a set

$\quad r$ = items selected from the set

#### Problems on permutations and combinations:

As we mentioned in the introduction for this lesson, we will not only use permutations or combinations on the next problems, we will make use of all of the concepts and processes we have studied in our combinatorics chapter of this statistics course. Still, the next problems are designed for you to work through a variety of these topics in the same problem, instead of each problem focusing in only one kind of process. So, lets get to work!

__Example 1__

From a standard deck of 52 cards, how many 5-card poker hands can be formed in each case:
**1. $\quad$ straight flush - 5 cards in sequence, all of the same suit, e.g. 6, 7, 8, 9, 10?**

It is important to mention what each of the words define, because we will be looking at the straights for each suit, in order to find all of the possible straight flush hands that can be found.

With this being said, let us start by picking a suit: hearts. The lowest straight flush that can be found for a suit goes as A, 2, 3, 4 and 5.

While the highest straight flush possible goes as 10, J, Q, K A.

Therefore, the flushes that can be found from the heart suit go as follows:

As you can see, there are 10 possible straight flushes form the hearts suit, therefore, there are 10 possible flushes from each of the four possible suits.

Therefore, we have a total of 40 possible straight flushes in a deck of cards. This can be proved following the fundamental counting principle, where you multiply the possible events in each category to find the amount of different outcomes possible:

**2. $\quad$ four of a kind?**

So, let us find how many ways can we find a four of a kind in a 5-card hand drawn from a standard deck of cards:

Notice that out of 13 ranks, in order to contain a four of a kind, each hand of 5 cards must have cards of 2 different ranks: One of the ranks will be that of the four of a kind, while the fifth card not belonging to the four of a kind has the other rank.

Thus, the first thing to calculate is the total number of permutations possible to have four cards of the same rank, while having 2 out of 13 ranks in a hand: $n$ = 13 and $r$ = 2

Then, once you know the amount of permutations for the two ranks that can be on a hand, we notice that the order in which the cards are collected in a hand does not matter. Therefore, if we pay attention the cards that can be part of the 1st rank (or first selected rank) you have four possible cards in each of those positions, where the order of the cards does not matter; thus, for the first selected rank we can have the next possible combinations:

Taking into account $n$ = 4 and $r$ = 4 for this case, since you have four possible cards for four different positions.

The result in equation 4 makes sense! Because once you have selected a rank you have 4 cards, if you need them in four positions and do not care in which order (rule for combinations) then you will just have one possible combination!

For the second selected rank (from figure 3) this is not as easy, because once you select a rank, you only have ONE position. Therefore, to calculate the possible combinations you can have in there we have that $n$ = 4 and $r$ = 1, and so:

With the results coming from equations 3, 4 and 5 we can clearly see that there are three categories containing different events that one must take into account to obtain all of the possible ways a four of a kind can come up in a 5-card hand:

- The number of permutations for two out of thirteen ranks in one 5-card hand
- The possible combinations of cards in the first rank selected
- The possible combinations of cards in the second rank selected

We follow the fundamental counting principle and multiply the possibilities for each category in order to find our final result:

*possible ways for 4 of a kind in a hand*= $(_{13}P_{2}) (_{4}C_{4})(_{4}C_{1})$

**3. $\quad$ full house - 3 of a kind and a pair, e.g. 5, 5, 5, 8, 8?**

With this, we just follow the exact same method as before and define the three categories containing different events that one must take into account to obtain all of the possible ways a four of a kind can come up in a 5-card hand:

- The number of permutations for two out of thirteen ranks in one 5-card hand
- The possible combinations of cards in the first rank selected
- The possible combinations of cards in the second rank selected

And so we have that:

*possible ways to have full house*= $(_{13}P_{2}) (_{4}C_{3})(_{4}C_{2})$

The first factor in equation 7 refers to the amount of permutations possible for two ranks to be selected in the hand out of the total thirteen; this is the same permutations we calculated in part 2. Then the two other factors refer to the combinations of total four cards in a rank and the 3 possible in the first rank selected, and the two possible in the second rank selected.

Therefore, the final result is:

*possible ways to have full house*= $(_{13}P_{2}) (_{4}C_{3})(_{4}C_{2})$

So there are 3,744 ways in which we can obtain a full house hand!

**4. $\quad$ flush - all 5 cards are of the same suit?**

- For each suit, the total amount of possible flushes are: $_{13}C_{5}$
- There are 4 suits, therefore the total amount of flushes in the card deck is: $_{13}C_{5} \times 4$
- The flushes we are talking about here are NOT straight flushes (calculated in part 1). Therefore we need to subtract those from the total amount of flushes in a deck to obtain the total number of pure flushes in the card deck.

With all of this being said, the total amount of pure flushes in the card deck is:

*pure flushes*$= (_{13}C_{5})(4) - 40 = (\frac{13!}{(13-5)! \, 5!})(4) - 40 = (\frac{13!}{(8!)(5!)} ) (4) - 40$

*pure flushes*$=(\frac{13\times12\times11\times10\times9}{5\times4\times3\times2\times1} )(4) - 40 = (13 \times 12 \times 11 \times 3) - 40 = 5,108$

__Example 2__

There are a total of 50 numbers in a combination lock, which unlocks with a three number sequence.
**a) $\quad$ How many possible combinations (sequences) are there for this lock?**

Notice that in this problem, we are asked to compute what people would usually call the combination for the lock, or how many combinations can the lock have; still, this problem is not talking about combinations as they are defined mathematically, this problem is asking to calculate the different permutations for the lock!

Why? Well, in order to find the lock combination you KNOW that this combination needs to have its contained numbers in a particular order or it wont open the lock, and since order matters, this means this is in reality a permutation of three numbers from the total set of 50 possible numbers.

Having said this, let us calculate all the possible PERMUTATIONS that a 50-number combination lock can have when is opened by a three number sequence.

We have that $n$ = 50 and $r$ = 3. Therefore:

And so, there are a total of 117,600 different ways that could serve as the lock code to be opened.

**b) $\quad$ Now, a master thief says that he only needs to know the 3 numbers out of the total 50 that are required to unlock the lock, no need to know how they arranged, if he finds out which three are used, he could open this lock. How many possible combinations of three numbers are possible to be the password of this lock?**

Remember, in this case we are looking for combinations, and so, we just need to find out the three numbers that are in there, but not how they are arranged. And so, we use the combinations formula having $n$ = 50 and $r$ = 3.

**c) $\quad$ Do you think this thief could open the lock once he has found out the three numbers that are necessary, even if he doesnt know in which order they should go?**

Yes, this could be easily done right? If you think about it, once the thief knows the exact three numbers required he is left with three numbers to be ordered in three positions, which means that the total possible arrangements of these three numbers, as learnt in our lesson on the factorial notation, is just equal to

**3! = 6**. And so, it sounds very simple to think the thief could just try and check for all the 6 ways individually until one of those opens.

The difficult part is to identify WHICH THREE-NUMBER COMBINATION TO USE OUT OF 19,600! (all possible combinations found in part b). Therefore, if he is bragging that he can open a lock when he knows already which three to use, then he doesnt really know how to open a lock (GOOD!).

We hope these examples were useful to you. See you in the next lesson!