# Safe probability problem

Let's say that you own a safe. You want to know what is the chance of you opening it because you have just forgot the combination to open it.

The safe combination has these features: you need to choose 8 from these numbers 1,2,3,4,5,6,7,8,9,0 and add A or B to the end of the combination. So if the combination was 12345678A, it would be different than 12345678B.

You can repeat numbers but not letters. There can be only 1 letter, and it has to be at the end of the combination, and the order matters.

Then you remember that the combination is a combination of the numbers 4,5,6 and it ends with B you just don't know in what order and how many times each number has been used.

The question is what is the probability that you get the combination right? At least I want to know how to start tackling the problem. Guidance or an answer is what I want.

• @zoli Latin wolf said that it has a combination of 4,5,6 that means it should contain atleast one 4,one 5 and one 6.Your $3^8$ contains solution such as {44444444,44444455,....etc} – NewGuy Mar 25 '18 at 22:34
• @NewGuy: You are right. I delete my comment... – zoli Mar 25 '18 at 22:37
• So if the number of combinations is $C$ then is $C < 3^8$ – Latin Wolf Mar 25 '18 at 22:40
• The figure $3^8$ counts how many combinations containing no digits other than $4,5,6$. If you insist each digit $4,5,6$ must occur at least once, this narrows the number of possibilities slightly, but the choice of $A,B$ at the end will double the number of possibilities. In any event that is a big number of combinations to try. – hardmath Mar 26 '18 at 0:26

how many 8 digit number we can form with using {4,5,6} such that you have atleast one 4,one 5 and one 6??

Total(S) = 8 digit number without any restrictions = $3^8$

$A_1$ = 8 digit number only using one unique digit = $\binom{3}{1}1^8$

$A_2$ = 8 digit number only using 2 unique digit = $\binom{3}{2}(2^8-2)$

$A_3$ = 8 digit number only using 3 unique digit

Now

$S = A_1+A_2+A_3$

$A_3 =3^8 - \binom{3}{1}1^8 -(\binom{3}{2}(2^8-2))$

• Using the Inclusion-Exclusion Principle, we could write the answer in the equivalent form $3^8 - \binom{3}{1}2^8 + \binom{3}{2}1^8$. Your answer is, of course, correct. – N. F. Taussig Mar 27 '18 at 14:44