# Combinations and permutations example problems with solutions

## Table of contents

- Introduction
- Playing cards
- Playing cards four of a kind
- Playing cards one ace in each hand
- Probability of selecting marbles
- Probability of selecting two balls of the same color
- Forming a team
- Color signals
- California license plate numbers
- Computer language symbols
- Men and women
- Cars and drivers
- Defective antennas
- Car parking
- Random number
- Subsets using binomial theorem
- Making binary numbers
- 3 Ants triangle puzzle

## Introduction

In this post, we are going to provide a couple of probability practice questions and answers. We are going to use combinations and permutations technique to do the counting part.

Let us get started…

## Playing cards

In playing cards what is the probability to get exactly one pair (for example (1,1), (2,2)) if we draw 5 cards

**Solution**

Step one is to compute how many possibilities we have if we draw 5 cards without any restriction. The answer is simply 52 choose 5 which is given by the well known formula:

1 |
n!/(n-k)!k! = 52!/47!5! = 2598960 |

The second step is to compute the number of possibilities we can draw 5 cards 2 of which are pairs. Here is how we do that:

- We have 13 numbers so choosing 1 of 13 is given by 13 choose 1
- Once the number is selected we need to choose two colors from four which is given by 4 choose 2
- Choose 3 numbers from the remaining 12 numbers = 12 choose 3
- For each number of the three choose a color from 4 colors = 4 choose 1

So the total number of possibilities:

1 2 3 |
(13 C 1)(4 C 2)(12 C 3)(4 C 1)(4 C 1)(4 C 1) = 13 x 4!/2!2! x 12!/9!3! x 4 x 4 x 4 = 1098240 |

Probability = 1098240/2598960 = 42.3 %

## Playing cards four of a kind

5 cards are randomly drawn from a standard 52 card deck. What is the probability to get four of a kind. For example 4 different aces plus some additional card

**Solution**

The total number of ways to choose 5 cards from 52 cards is straight forward and given by the formula n choose k where n = 52 and k = 5

1 |
(52 C 5) = (52!/(47! x 5!)) = 2598960 |

The tricky part in this question is calculating the total number of combinations that yield to four of a kind. Here is how we do that

- There are 13 ways to choose 1 number from 13 numbers (easy)
- Once a number is chosen there is no need to choose a color simply because there are 4 colors available and we need 4 but if you want to apply the formula then it is choosing 4 from 4 and there is only one way to do that.
- The third step is to choose one number for the fifth card from the remaining 12 numbers
- The last step is to choose a color for the fifth number from 4 colors available. So the total number of combinations is

1 |
(13 C 1) x (4 C 4) x (12 C 1) x (4 C 1) = 13 x 1 x 12 x 4 = 624 |

To calculate probability just divide the two numbers above

1 |
probability = 624/2598960 |

## Playing cards one ace in each hand

In playing cards what is the probability that each of the four players gets an ace

**Solution**

Each player gets 13 cards out of 52 so there are:

1 2 |
(52 choose 13)(39 choose 13)(26 choose 13)(13 choose 13) = (52!/39!13!)(39!/26!13!)(26!/13!13!) |

different ways to distribute 52 cards among the four players.

There are 4 aces already out of 52 so the number of ways to distribute the remaining 48 cards on the four players is given by:

1 |
(48 choose 12)(36 choose 12)(24 choose 12)( 12 choose 12) |

which means there:

1 2 |
4! (48 choose 12)(36 choose 12)(24 choose 12)( 12 choose 12) = 4!(48!/36!12!)(36!/24!12!)(24!/12!12!) |

different ways that each player gets an ace. The reason why we multiply by 4! is becuase each player can have any one of the four aces so we have 24 combinations. For each one of these combinations we need to distribute the remaining 48 cards on the four players.

So the probability that each player gets an ace is given by:

1 |
4!(48!/36!12!)(36!/24!12!)(24!/12!12!)/(52!/39!13!)(39!/26!13!)(26!/13!13!) = 10.5% |

## Probability of selecting marbles

A bag of marbles containing 4 white marbles and 6 red marbles. If we randomly select two marbles from the bag what is the probability that the selected marbles are of different colors in other words one white and one red

**Solution**

Selecting (k) objects from (n) objects is given by:

1 |
n!/(n-k)!k! |

so the total number of outcomes for this experiment is:

1 |
10!/(10-2)!2! = 45 |

where 10 is the total number of marbles in the bag and 2 is the number of selected marbles

Selecting one white marble from 4 is given by 4 choose 1 = 4!/(4-1)!1! = 4

Selecting one red marble from 6 is given by 6 choose 1 = 6

Total number of ways we can select one red and one white = 4 x 6 = 24

So the probability to select one red and one white = 24/45

There is another way to solve this problem by noting that the probability to select one white and one red is the sum of the probability of selecting white marble first then red marble next and the probability of selecting red marble first then white marble next:

1 2 3 |
P(white and red) = P(white then red) + P(red then white) = (4/10)(6/9) + (6/10)(4/9) = 24/45 |

Note that the probability of selecting white marble first is 4/10 because we have 4 white marbles and 10 marbles in total and the probability of selecting red marble after selecting white marble is 6/9 because we have 6 white marbles and 10-1 = 9 total marbles after we selected the first marble. We multiplied both probabilities because we used the conditional probability rule which states that:

1 |
P(A/B) = P(AB)/P(B) |

## Probability of selecting two balls of the same color

You have 6 red balls, 7 green balls and 4 blue balls. You are asked to choose two balls. How many different ways you can select the balls if the color should match. How many different ways you can select the balls if the color does not match.

**Solution**

There are 6 choose 2 different ways to select red balls and 7 choose 2 different ways to select green balls and 4 choose 2 different ways to select blue balls:

1 2 3 |
6 choose 2 = 6!/4!2! = 15 7 choose 2 = 7!/5!2! = 21 4 choose 2 = 4!/2!2! = 6 |

So the total number of ways to select two balls of the same color

1 |
15 + 21 + 6 = 42 |

If the color does not match then we need to select one red and one green, one red and one blue or one green and one blue. There are 6 ways to select a red ball and 7 ways to select a green ball so we have 42 ways to select the first pair. The second pair is 6×4 = 24 and the third pair is 7×4 = 28

So the total number of ways to select two balls with different color

1 |
42 + 24 + 28 = 94 |

## Forming a team

A group of 4 boys and 3 girls. We want to form a team of 5 players. We are required to select 2 girls and 3 boys. If 2 boys can not play together. How many possible ways we can form the team.

**Solution**

Let us break this problem into steps. The first step is to compute how many ways we can form a group of 2 girls from the available 3 girls. The answer is 3 ways as follows:

1 2 3 |
G1G2 G1G3 G2G3 |

In other words we are selecting (r = 2) objects from (n = 3) objects while the order is not important. This is known as (n) choose (r) and given by the formula n!/(n-r)!r! Substituting we get 3!/(3-2)!2! = 3 ways

The second step is to compute how many ways we can choose 3 boys from 4 boys. Apply the same formula we get 4!/(4-3)!3! = 4 ways as follows:

1 2 3 4 |
B1B2B3 B1B2B4 B1B3B4 B2B3B4 |

The third step is to exclude groups of boys containing the two boys who can not play together. Take those two (the ones who can not play together) out of the four (total number of boys) then we are left with two boys from which we need to select one (because the total that we need to select is three). There is only one way to select the two who can not play together and two possible ways to select the third player from the remaining two (total = 1 x 2 = 2) For example, assuming B1 and B3 can not play together then we are left with the following:

1 2 |
B1B2B4 B2B3B4 |

The fourth step is to multiply all the numbers that we computed excluding the two in the third step so the final answer is:

3 x (4 – 2) = 6 ways as follows:

1 2 3 4 5 6 |
G1G2B1B2B4 G1G2B2B3B4 G1G3B1B2B4 G1G3B2B3B4 G2G3B1B2B4 G2G3B2B3B4 |

## Color signals

You are given 1 red flag, 2 green flags and 3 blue flags. You are asked to generate 6 symbol based signals using these flags. How many signals you can generate.

**Solution**

This problem can be solved using permutations counting techniques. We have 6 symbols in total but note that they are not distinct. For example if we have 6 different symbols then the number of permutations or different signals that we can generate is 6 factorial however in our case we have 3 symbols (R G B) and

a 6 color signal so we need to divide the 6! over (3! x 2! x 1!). The final answer is 6x5x4x3x2/3x2x2 = 60

Here is a simpler example to demonstrate this concept. If we have the letters ABC then we can arrange them in 3! or 6 different ways as follows: ABC, ACB, BAC, BCA, CAB, CBA but if we have AAB then it 3!/2!x1! = 3 different ways as follows: AAB, ABA, BAA

In general there are n!/(n1! x n2! … x nr!) different ways to arrange n objects of which n1 objects are alike, n2 objects are a like and so on up to r.

## California license plate numbers

A typical car license plate number in California starts with a decimal digit then three capital letters then three decimal digits. If repetition is not allowed and we need to generate a license plate number randomly, what is the probability that we will get a three letter sequence “ABC” in the generated license plate number.

**Solution**

This is a counting problem which can be solved using the basic counting principle. A decimal digit can range from 0 to 9 which means 10 different outcomes while a capital letter can range from A to Z which means 26 outcomes. The license plate number has 7 symbols (1 digit + 3 letters + 3 digits) so we need to perform a chain of multiplications to compute the total number of outcomes as follows:

1 |
Total number of outcomes = (10) x (26 x 25 x 24) x (9 x 8 x 7) |

Since repetition is not allowed we multiply by 25 instead of 26 after we choose the first letter then we multiply by 24 instead of 26 after we choose the second letter, similarly we multiply by 9 instead of 10 after we choose the second digit and so on. If the three letters sequence ABC is fixed in the license plate number then we have (10) x (1 x 1 x 1) x (9 x 8 x 7) possibilities

So the probability to get that is

1 |
(10 x 9 x 8 x 7) / (10 x 26 x 25 x 24 x 9 x 8 x 7) = 1/5040 |

## Computer language symbols

A computer language is usingÂ 10 symbols and 26 letters. How many 6 digit words can be constructed using 3 different letters and 3 different symbols. How many different symbols can be constructed if the word has to start with letter Z for example.

**Solution**

For the first part of the question we need to choose 3 symbols from 10Â and 3 letters from 26. This means

1 |
(10 C 3) x (26 C 3) |

This gives usÂ the total number of combinations but order does matter so we need to permute the 6 digits by multiplying the value above by 6 factorial. The total number of words is

1 2 3 |
(10 C 3) x (26 C 3) xÂ 6! = (10!/(7!x3!)) x (26!/(23!x3!)) x 6! = 224640000 |

For the second part of the question we need to choose 2 letters from 25 because the first letter has been already chosen for us which is z and we need to choose 3 symbols from 10. This means

1 |
(10 C 3) x (25 C 2) |

Similarly since order is important we need to permute the individual digits by multiplying the number above by 5 factorial. Recall that the first character is fixed so instead of permuting 6 digits we permute 5 digits. The total number of words in this case is

1 2 3 |
(10 C 3) x (25 C 2) x 5! = (10!/(7!x3!)) x (25!/(23!x2!)) x 5! = 4320000 |

## Men and women

How many different couples we can make if we are asked to select 5 women from 10 candidates and 5 men from 12 candidates.

**Solution**

There are 10 choose 5 different ways to select the women:

1 |
10!/(10-5)!5! = 252 |

There are 12 choose 5 different ways to select the men:

1 |
12!/(12-5)!5! = 792 |

Total number of combinations:

1 |
252 x 792 = 199584 |

We are not done yet because we need to pair 5 men with 5 women so the number of combinations should be multiplied by 5! because the first man can choose any women from 5, the next man can choose any one of the remaining 4 and so on.

So the total number of ways:

1 |
199584 x 5! = 23950080 |

## Cars and drivers

We have 4 drivers and 4 cars. If two cars can only be driven by two drivers and the other two cars can be driven by any driver. How many different ways the drivers can drive the cars.

**Solution**

Let us assume driver 1 and driver 2 can only drive car 1 and car 2. This condition is going to restrict the other two drivers 3 and 4 even though they can driver car 1 and car 2 as well. Here is the enumeration of all different combinations:

1 2 3 4 5 |
D1 D2 D3 D4 C1 C2 C3 C4 C1 C2 C4 C3 C2 C1 C3 C4 C2 C1 C4 C3 |

As you can see the total number of ways is 4 on the other hand if there is no restriction on which cars the drivers can drive then there are 4! = 24 different ways.

## Defective antennas

Consider the system where we have a chain of 4 antennas lined up next to each other. In order for the system to be functional no two defective antennas should be lined up next to each other. Given that 2 antennas are defective, what is the probability that the system is functional.

**Solution**

We have 4 antennas, each one can be functional or not, this is similar to a 4 digit binary number where we have 16 combinations, a 0 in a given digit means the corresponding antenna is defective while a 1 means the corresponding antenna is functional. Here are all combinations

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
0 0 0 0 x 0 0 0 1 x 0 0 1 0 x 0 0 1 1 0 1 0 0 x 0 1 0 1 0 1 1 0 0 1 1 1 x 1 0 0 0 x 1 0 0 1 1 0 1 0 1 0 1 1 x 1 1 0 0 1 1 0 1 x 1 1 1 0 x 1 1 1 1 x |

Note that we need to exclude those combinations where we do not have 2 defective antennas simply because we are given that 2 antennas are defective so the total number of outcomes is reduced from 16 to 6, now count the number of outcomes where no two defective antennas are next to each other, here is the list of antennas that satisfy this condition:

1 2 3 4 5 6 |
0 0 1 1 0 1 0 1 x 0 1 1 0 1 0 0 1 x 1 0 1 0 x 1 1 0 0 |

As you can see we have 3 out of 6 so the probability is 3/6

## Car parking

In a parking lot there are (4) trucks, (3) SUVs, (2) Sedans and one motorcycle. We need to park the cars such that cars of the same type are next to each other. For example all trucks are adjacent to each other, SUVs are next to each other and so on. How many different ways we can do that.

**Solution**

This is a typical combinatorial analysis counting problem. The basic counting principle says if you have an experiment involving multiple phases then the total number of outcomes is equivalent to the multiplication of the number of outcomes contributed by each phase. So we need to multiply the number of outcomes from arranging trucks, SUVs, Sedans and motorcycles. For each group of cars for example trucks you can calculate the number of outcomes or permutations by computing the factorial of the number of vehicles in each group. In other words we have 4! ways to arrange the trucks, 3! ways to arrange the SUVs, 2! ways to arrange the sedans and 1! to arrange the motorcycles. The total number of ways is 4! x 3! x 2! x 1! = 288 ways.

Are we finished? the answer is no ! simply because we have 4 groups of vehicles for which we have 4! ways to arrange them. Note that we are referring here to the vehicle types not to the number of cars per group. Regardless of how many ways we can arrange the cars in a given group still where to put the group with respect to other groups is a different issue. For example do we want to put the trucks far to the left? far to the right ? in the middle, etc. So the grand total number of ways is 4! x 288 = 6912 ways.

## Random number

We want to generate a random number between 100 and 499. what is the probability of generating a random number which has at least one digit = 1 for example 115. What is the probability of generating a random number that has exactly two digits = 2 for example 221

**Solution**

Let us first compute the total number of random numbers that we can generate between 100 and 499. The answer is simply:

1 |
4x10x10 = 400 different numbers |

- Numbers having first digit = 1 are of the form 1BC and there are 1x10x10 = 100 ways
- Numbers having second digit = 1 are of the form A1C and there are 4x1x10 = 40 ways
- Numbers having third digit = 1 are of the form AB1 and there are 4x10x1= 40 ways

Repeated numbers between 1 and 2 above = 10

Repeated numbers between 1 and 3 above = 10

Repeated numbers between 2 and 3 above = 4

Repeated numbers between 1 and 2 and 3 above = 1

Numbers having at least one digit = 1 is the union of all numbers in 1, 2 and 3. If we have three events A, B and C then the probability of the union is given by

1 |
P(A) + P(B) + P(C) - P(AB) - P(AC) - P(BC) + P(ABC) |

Substituting the values we calculated earlier we get:

1 2 |
100/400 + 40/400 + 40/400 - 10/400 - 10/400 - 4/400 + 1/400 = 157/400 possibilities |

There is a faster way to solve this problem. Recall that the probability of an event is one minus the probability of the complement of that event. Also note that Demorgans rule suggests that the complement of the union is equivalent to the intersection of the complements as demonstrated below for some event E:

1 |
P(E) = 1 - P(EC) where EC is the complement of E |

if E is the union of E1, E2 and E3 then complement of E is the intersection of E1C, E2C and E3C where E1C is the complement of E1, etc. If E1 represents the event of generating a number having the first digit = 1 then the complement is the event of generating a number that does not have the first digit = 1 and so on for E2 and E3. We are interested in the intersection of those events which means the first digit is not 1 and the second digit is not 1 and the third digit is not 1. There are 3 ways to choose the first digit, 9 ways to choose the second digit and 9 ways to choose the third digit. The total number of ways is 3x9x9 = 243 so the probability can be computed as:

1 |
1 - 243/400 = 157/400 |

Regarding the second part of the question. The probability to generate a random number having **Exactly** two digits of of 2 must have the following form:

1 2 3 |
A22 2B2 22C |

From the above forms there 3 possibilities for the first one, 9 possibilities for the second one and 9 possibilities for the third one. Notice that 222 is not an option that is why we have 3 instead of 4 and 9 instead of 10 So the total number of ways is:

1 |
3 + 9 + 9 = 21 |

which means the probability to generate a random number having two digits of 2:

1 |
Probability = 21/400 |

## Subsets using binomial theorem

How many subsets we can make from the numbers between 1 and 5

**Solution**

The naive way to compute that is to enumerate all possibilities as follows:

Groups of 1:

1 |
1, 2, 3, 4, 5 |

Groups of 2:

1 |
12, 13, 14, 15, 23, 24, 25, 34, 35, 45 |

Groups of 3:

1 |
345, 245, 235, 234, 145, 135, 134, 125, 124, 123 |

Groups of 4:

1 |
1234, 1235, 1245, 1345, 2345 |

Groups of 5:

1 |
12345 |

So the answer is 31 subsets. A better way is to calculate the sum of all (5 choose k) where k goes from 1 to 5 using the formula m choose k:

1 2 3 |
m!/(m-k)!k! = 5!/4!1! + 5!/3!2! + 5!/2!3! + 5!/1!4! + 5!/0!5! = 5 + 10 + 10 + 5 + 1 = 31 |

The fastest way to compute this quantity is by noting that the Sum of (5 choose k) where k goes from 1 to 5 is (1 + 1)^5 – 1 = 31 using the binomial theorem which states that:

1 |
(x + y)^n = Sum [ (n choose k) x^k y^n-k] where k goes from 0 to n |

## Making binary numbers

Given four binary digits all ones 1111 and two binary digits all zeros 00 we need to create a six digit binary number using these ones and zeros such that no two zeros are next to each other. How many binary numbers we can make. For example 011110 is correct while 110011 is not correct.

**Solution**

In order for the two zeros (00) not to be next to each other they should occupy any position marked as (x) in the following pattern:

1 |
x 1 x 1 x 1 x 1 x |

Here are the possible ways:

1 2 3 4 5 6 7 8 9 10 |
0 1 0 1 1 1 0 1 1 0 1 1 0 1 1 1 0 1 0 1 1 1 1 0 1 0 1 0 1 1 1 0 1 1 0 1 1 0 1 1 1 0 1 1 0 1 0 1 1 1 0 1 1 0 1 1 1 0 1 0 |

as you can see we have 10 possible ways. What if we have more digits ? in that case enumerating all possible ways becomes very difficult. A smarter way is notice that this is an (m) choose (k) problem where (m) is the total number of available (x) positions which is nothing but number of ones plus one and (k) is the number of zeros. (m) choose (k) can be calculated using the formula:

1 |
Total = m!/(m-k)!k! = (4+1)!/(4+1-2)!2! = 5!/3!2! = 10 |

## 3 Ants triangle puzzle

Three ants on the corners of an equilateral triangle. They started moving along the edges at the same speed. What is the probability that the ants will collide ?

**Solution**

Each ant could possibly be moving in one direction let us say Left or Right. We have three ants with two possible directions each. The total number of combinations is Eight. There are only two combinations in which a collision can not happen which is when the ants are going all in the same direction ie clockwise or counterclockwise so we have six combinations that can lead to a collision which means the probability of collision is 6/8. This problem has the analogy of a three digit binary number that runs from zero to seven or from 000 to 111 in binary. Collision can not happen when we have 000 or 111.

That is all, thanks for visiting. If you have a question, please leave a comment below…