# Combinatorics and probability: size of sample space

I'm having a tough time finding the next example's sample space's size:

We have at our disposal the following: the three letters $\;a,b,c\;$ , and the five digits $\;1,2,3,4,5\;$ . We have to form with them all the possible passwords of six ($\;6\;$) characters, under the condition that there must be at least one letter and at least one number in each password. Other than this there are no more restrictions (and, thus, one can repeat at will numbers, letters and etc.)

What I tried: I fixed one letter and one digit, thus getting $\;3\cdot 5=15\;$ possibilities fir each fixation (?), and for the other $\;4\;$ characters needed in the password I have $\;8\;$ possibilities for each (as repetitions are allowed), rendering $\;8^4\;$ possibilities.

I further thought of multiplying the above by two to indicate that the first two characters I chose can be interchanged, and finally I multiplied by $\;\binom 62=15\;$ possibilities to place them within the six places of the password.

All in all, the above says there are $\;15\cdot8^4\cdot2\cdot\binom65\;(**)$ possibilities

All fine...but there are repetitions! For example, suppose for simplicity I have fixed the characters $\;a,1\;$ , and say I place them in positions $\;2-3\;$ . But then one possible password is $\;1-a-1-1-1-1\;$ , yet if I swap my fixed characters in these positions I get the password $\;1-1-a-1-1-1\;$ , which already appears when the positions $\;2-3\;,\;2-4\;,\;2-5\;,$ etc. are chosen.

Thus, the number (**) abo0ve is way over the actual number I'm seaching, and I'm about to become a friar in Malta out of desperation, so any help will be greatly appreciated.

• I believe you have $5$ digits instead of $3$? (second line of your post) Commented Apr 28, 2014 at 16:37
• Sometimes it's easier to count all configurations and then subtract the ones that don't work than it is to count only good configurations. Commented Apr 28, 2014 at 16:41
• Yes @jnh, thank you. Commented Apr 28, 2014 at 18:22

The set of elements you can choose from is this: $\{a,b,c,1,2,3,4,5\}$. Then you know that you will be dealing with permutations with repetition. So, the formula for permutations with repetition is $n^r$, where $n$ is the number of elements to choose from and $r$ is the number of them you can choose.
With all this said, then since we need to choose $6$ of them from the set of $8$ elements, then we have $8^6$ total permutations.
Now, this total includes passwords that are all numbers and all letters, so we need to subtract those from the total number of permutations.

For the total number of passwords with all letters, it is $3^6$, since there are $3$ letters and we are choosing $6$ of the them (all permutations with repetition allowed). This is similar for a password with all numbers, which would be $5^6$ since there are $5$ numbers.

This gives total possible passwords without all letters and all numbers is $$8^6-5^6-3^6=245790$$

• Thank you very much. This really helped. +1 Commented Apr 28, 2014 at 18:25
• You are very welcome! Commented Apr 28, 2014 at 18:26
• Both answers are great and I can't know for sure who posted first, so I'm going to upvote yours because I think this one was slightly earlier and because of your comment below my question remarking a typo. Commented Apr 28, 2014 at 18:27

Given no restrictions other than the allowed characters, how many passwords can we make? There are 8 possible characters, and the password length is 6, so $8^6$.

How many passwords can we make with only letters? There are 3 possible characters, and the password length is 6, so $3^6$.

How many passwords can we make with only numbers? There are 5 possible characters, and the password length is 6, so $5^6$.

If you take all possible passwords and remove all with only letters and all with only numbers, you get all the passwords that must have at least one letter and number.

$$8^6-5^6-3^6=245790$$

• Very clear, thank you very much. +1 Commented Apr 28, 2014 at 18:23