how many 4 digits passwords contains 2 same digits in a row

68 Views Asked by At

how many 4 digits passwords contains 2 same digits in a row : and for example the passwords : 4442 , 1111 is correct. i think its by the Inclusion–exclusion principle , but dont know how to solve it.

3

There are 3 best solutions below

0
On

Hint:

The number of passwords that never have any $2$ same digit in a row is simpler to count. Try to construct the passwords from the left to right. As you construct the $i$-th digit, make sure it is different from the $(i-1)$-th position.

2
On

Let $E_i$ denote the set of passwords $D_1D_2D_3D_4$ where $D_i=D_{i+1}$.

Then to be found is $|E_1\cup E_2\cup E_3|$.

Now apply inclusion/exclusion.


edit:

$$|E_1\cup E_2\cup E_3|=$$$$|E_1|+|E_2|+|E_3|-|E_1\cap E_2|-|E_1\cap E_3|-|E_2\cap E_3|+|E_1\cap E_2\cap E_3|=$$$$3\cdot10^3-3\cdot10^2+10=2710$$

0
On

It is easier to find the 4-digit passwords that do not have $2$ same digits in a row, then take the number of 4-digit passwords possible and subtract by the passwords that don`t have $2$ digits in a row.

There are the numbers 1-9 that you could use in the first position, so there are 9 possible solutions for the first position. Then, there are $9$ possible solutions that do not use the number in the first position. Keep applying the same method to find the number of 4-digit passwords that do not have $2$ digits in the same row.