# Permutations vs Combinations: Probability & Statistics

I need help with the following exercise as I am preparing for my exams on my own and never had the chance to visit any workshops or lectures as they were not offered, so here it goes.

A lock can be opened using a code with 3 digits. a) (i) How many codes are possible? (ii) How many codes when there's at least a number 5 in the code? (iii) How many codes when there's exactly a number 5 in the code? (iv) How many codes with their last digit being an even number?

(b)Now the 3 digits will be different from one another. (i) How many codes are possible? (ii) How many codes with their last digit being an odd number? (iii) How many codes when there is at least a number 1 in the code?

Thank you in advance for anyone able to explain me!

## 1 Answer

a) Denote with $$P(i)$$ the number of possibilities there is for the event $$i$$.

i) For the units, the tens and the hundreds, you have respectively 10 different digits $$(0,1,2,3,4,5,6,7,8,9)$$ you can choose.

Thus

$$P(i)=10\times10\times10=10^3=1000$$

ii) We now know, that at least one of the digits is a 5, which implies that in fact, one of them is a 5 and the others can be any digit:

$$P(ii)=1\times10\times10=10^2=100$$

You can alternatively think this: From the thousand possibilities in $$P(i)$$, how many of them contain one five or more, i.e. how many of them start, for instance, with a 5?

iii) If there is exactly one 5, the other two digits can't be a 5, which implies that they can only be 9 digits $$(0,1,2,3,4,6,7,8,9)$$. Hence

$$P(iii)=1\times 9\times9=9^2=81$$

iv) There are exactly 5 even digits $$(0,2,4,6,8)$$. Since the tens and the hundreds have no restriction

$$P(iv)=10\times 10\times 5=10^2\times 5=500$$

Hint for the part b)

If the three digits can be the same, once you've chosen one digit from the ten you have for the units (for instance), you'll only have nine left to choose for the tens. And once you've chosen the digit for the tens (different from the units), you'll only have 8 digits left to choose for the hundreds.

You can see the solutions here. I recommend you, however, to try to do it yourself first ;)

$$P(i)=10\times 9\times 8=720$$ $$P(ii)=5\times 9\times 8=360$$ $$P(iii)=1\times 9\times 8=72$$

• Thank you so so much! For a) (i) vs b) (i) - I somehow thought that the order matters for both since, let's say as it is a lock: 321 will be different than 123. And with the solution provided for a) (i) - n on the kth, does this disregard order (as in, order doesn't matter)? I hope I made sense haha. – user624631 Dec 9 '18 at 20:57