Combinatorics: If my phone has a $5$-pin code to unlock it but I only remember $3$ digits, what are the outcomes?

148 Views Asked by At

Let's say I remember there were $2$, $3$ and $4$. How can I calculate possible outcomes for my pin code? Do I use the combination with repetition formula? But since the order of the pin matters shouldn't I just use permutations?

Would the number of possibilities then be: $10\cdot 9\cdot 8\cdot 5=3600?$

3

There are 3 best solutions below

1
On BEST ANSWER

We consider cases.

One digit appears three times and two other digits each appear once: In this case, the only digits that may appear in the PIN are $2$, $3$, and $4$. Choose which of them appears three times. Choose three of the five positions for that digit. The remaining two numbers can be placed in the remaining two positions in $2!$ ways.

Consequently, there are $$\binom{3}{1}\binom{5}{3}2!$$ such PINS.

Two digits appear twice and a third digit appears once: Again, the only digits that may appear in the PIN are $2$, $3$, and $4$. Choose which two of the three digits are repeated. Choose two of the five locations for the smaller of these two digits. Choose two of the remaining three locations for the larger of these two digits. The remaining number must be placed in the remaining position.

Consequently, there are $$\binom{3}{2}\binom{5}{2}\binom{3}{2}$$ such PINS.

One digit appears twice and three other digits appear once each: Since four digits are used, there must be a digit other than $2$, $3$, and $4$. There are $10 - 3 = 7$ possibilities for this digit. Choose which of the four digits that appear in the PIN appears twice. Choose two of the five locations for that digit. The remaining three digits can be arranged in the remaining three locations in $3!$ ways.

Consequently, there are $$\binom{7}{1}\binom{4}{1}\binom{5}{2}3!$$ such PINS.

Five digits each appear once: There are two digits other than $2$, $3$, and $4$. There are $\binom{7}{2}$ ways to select these digits and $5!$ ways to arrange the five digits in the PIN.

Consequently, there are $$\binom{7}{2}5!$$ such PINS.

Since these cases are mutually exclusive and exhaustive, the desired answer can be found by adding the results of the above cases.

0
On

Lets say you want to guess a sequence $s = (s_1,...,s_n)$ of $n \in \mathbb{N}_{\geq 1}$ digits . Each digit is a number in $\{0,...,9\}$. You remember, that $k \leq n$ particular (pairwise different) digits ${d_1,...,d_k}$ appear in $s$. You know that each $d_i$ appears exactly once in $s$ (which implies that $k \leq 10$) but you don't remember the position of the $d_i$. Under these assumptions, you can calculate the number of possible configurations of $s$ via:

$$ n*(n-1)...(n-k+1) * (n-k)^{10-k} $$

The term $n$ stands for the possible positions of $d_1$, the term $(n-1)$ stands for the possible positions of $d_2$ and so on. The term $(n-k)^{10-k}$ factors in the digits that do not belong to the $d_i$ and which can be chose freely among the $n-k$ digits which have not been used as a $d_i$ already.

8
On

In this answer it is preassumed that a pincode can be any $5$-digit number, and that it is known that the digits $2,3,4$ are among these digits.

Let $E_i$ denote the set of possible codes that do not contain digit $i$.

With inclusion/exclusion and symmetry we find:$$|E_2\cup E_3\cup E_4|=3|E_2|-3|E_2\cap E_3|+|E_2\cap E_3\cap E_4|=3\cdot 9^5-3\cdot8^5+7^5$$

so that: $$|E_2^{\complement}\cap E_3^{\complement}\cap E_4^{\complement}|=10^5-|E_2\cup E_3\cup E_4|=10^5-3\cdot 9^5+3\cdot8^5-7^5$$