[Math] How many 8-character passwords can be created with given constrains

combinatorics

How many unique 8-character passwords can be made from the letters $\{a,b,c,d,e,f,g,h,i,j\}$ if

a) The letters $a,b,c$ must appear at least two times.

b) The letters $a,b,c$ must appear only once and $a$ and $b$ must appear before $c$.

So for the first part I tried:

The format of the password would be $aabbccxy$ , where $x$ and $y$ can be any of the given characters.

So for $xy$, I have $10^2=100$ variations and for the rest, I can shuffle them in $\frac{6!}{(2! \cdot 2! \cdot 2!)}=90$ ways (the division is so they won't repeat) which makes total of $100*90=9000$ possibilities.

Now I don't know how to count the permutations when $x$ and $y$ are on different places. I wanted to do another permutation and multiply by $9000$, this time taking all $8$ characters in account, so I get $\frac{8!}{(2!\cdot 2! \cdot 2!)}$, but when $x$ and $y$ have the same value there still will be repetition.

As for the second I have no idea how to approach.

Best Answer

For the second one, let $Z(n)$ be the number of strings of length $n$ with none of $a,b,c$, $A(n)$ the number of strings of length $n$ that contain exactly one $a$ and no $b$ or $c$, $b(n)$ the number of strings of length $n$ that contain exactly one $b$ and no $a$ or $c$, $AB(n)$ the number of strings of length $n$ that contain exactly one $a$, exactly one $b$, and no $c$, and $C(n)$ the number of strings of length $n$ that contain one each of $a,b,c$ with the $c$ last. Then you can set up recurrences such as $Z(1)=7, Z(n)=7Z(n-1), A(1)=1, A(n)=7A(n-1)+Z(n-1)$. Do you see where these come from? A spreadsheet will make it easy to go through $n$-put $n$ in the rows and each of the functions in a column. Once you fill the formulas into the $n=2$ row, copy down gets you all the rows you want.

For the first, I would follow a similar approach to count the strings that don't have two of each and subtract that from the total number of strings.

Added: probably the solution your teacher is looking for in the second is that there are ${8 \choose 3}$ ways to choose the locations of $a,b,c$, $2$ ways to choose the order of $a,b,c$, and $7^5$ ways to choose the rest of the letters. This is easier than my earlier approach.