0

Password must be 5 characters of lowercase letters and digits. Must contain at least two letters and at least one digit with no repetition of digits.

I have so far: $$ 26^2 + 10 \cdot 9 \cdot 8 $$ plus $$ 26^3 + 10 \cdot 9 $$ plus $$ 26^4 + 10 $$ Am I on the right lines?

Matti P.
  • 6,012
toby843
  • 57
  • I'm sure I need to account for the positions of the letters etc but I just can't quite work out which formula to use for it. – toby843 Jun 17 '21 at 09:14
  • Does this help you answer your question? https://math.stackexchange.com/q/3455469 –  Jun 17 '21 at 09:19
  • First case for example is ${5 \choose 3} \cdot {10 \choose 3} \cdot 3! \cdot 26^2$ – Math Lover Jun 17 '21 at 09:19
  • 2
    you cannot add $26^2$ and permutations of digits. It should be multiplied. – Math Lover Jun 17 '21 at 09:20
  • what I have written above means - choose $3$ out of $5$ places for digits, choose $3$ digits out of $10$, permute them in places in $3!$ ways and finally for remaining two places, you have $26^2$ options of letters. Do it similarly for other two cases - with two digits and with one digit – Math Lover Jun 17 '21 at 09:22
  • Looking at your work, it seems like you have set out to separate this into three different cases: 3 digits; 2 digits and 1 digit. That's a good approach, but your calculations are not correct. For example, in the case of 3 digits, I'm sure that you mentally think "Okay so we have 2 letters, that's 26 squared, PLUS we have to choose three digits ... " But in this case you cannot use addition. You have to multiply those. – Matti P. Jun 17 '21 at 09:22
  • Last point - please learn to use mathjax! – Math Lover Jun 17 '21 at 09:24
  • Firstly, sorry about mathjax, I will try and learn it for sure. So I had a feeling I was missing the choose function. So as far as I can see then I have 3 options for layouts: 2 letters 3 numbers 3 letters 2 numbers 4 letters 1 number for each of these I apply the approach in the 3rd comment then add the results together. – toby843 Jun 17 '21 at 09:31
  • Just to clarify, the 5 choose 3 is nPr not nCr as we're talking permutations without repetition right? – toby843 Jun 17 '21 at 09:58
  • On second thoughts, I think it should be nCr as for those calculations the order doesn't matter as I'm just picking spots for number then numbers to go in the spots. The factorial stage then accounts for the order doesn't it. – toby843 Jun 17 '21 at 12:00

2 Answers2

1

You should identify each pattern and permute them. Because the letters can repeat, we treat each case individually.

  • $2$ different letters, $3$ different digits: $26\cdot25\cdot10\cdot9\cdot8\cdot5!/12$
  • $2$ same letters, $3$ different digits: $26\cdot10\cdot9\cdot8\cdot\frac{5!}{2}/6$

  • $3$ different letters, $2$ different digits: $26\cdot25\cdot24\cdot10\cdot9\cdot5!/12$
  • $2$ same letters, $1$ different letter, $2$ different digits: $26\cdot25\cdot10\cdot9\cdot\frac{5!}{2}/2$
  • $3$ same letters, $2$ different digits: $26\cdot10\cdot9\cdot\frac{5!}{6}/2$

  • $4$ different letters, $1$ digit: $26\cdot25\cdot24\cdot23\cdot10\cdot5!/24$
  • $2$ same, $2$ different letters, $1$ digit: $26\cdot25\cdot24\cdot10\cdot\frac{5!}{2}/2$
  • $2$ same, $2$ different same letters, $1$ digit: $26\cdot25\cdot10\cdot\frac{5!}{4}$
  • $3$ same, $1$ different letter, $1$ digit: $26\cdot25\cdot10\cdot\frac{5!}{6}$
  • $4$ same, $1$ digit: $26\cdot10\cdot\frac{5!}{24}$

To sum this, I used a spreadsheet:

spreadsheet

JMP
  • 21,771
  • OK, so that's not a way I'd thought of before. Interesting. I'll have to have a look and see if the answer is the same as the nPr way I've been looking at. – toby843 Jun 17 '21 at 11:05
0

There are three cases to consider: $2$ letters + $3$ digits, $3$ letters + $2$ digits, and $4$ letters + $1$ digit.

$2$ letters + $3$ digits: $$\binom{5}{2} 26^2 \binom{10}{3} 3!$$

$3$ letters + $2$ digits: $$\binom{5}{3} 26^3 \binom{10}{2} 2!$$

$4$ letters + $1$ digit: $$\binom{5}{4} 26^4 \binom{10}{1} 1!$$

Sum these three terms for the answer.

awkward
  • 14,736
  • This is interesting, you seem to be doing 5 choose the number of spaces for letters, whereas math lover above appears to be doing 5 choose the number of spaces for numbers. This will lead to different results I think. – toby843 Jun 17 '21 at 13:51
  • Wow, it actually produces the same result. So I've learnt something very important there. Thank you. – toby843 Jun 17 '21 at 14:38
  • @toby843 If you choose the spaces for the letters, the spaces for the numbers are forced; and if you choose spaces for the numbers, the spaces for the letters are forced. So the two approaches are equivalent. To put it another way (and more generally), $$\binom{n}{r} = \binom{n}{n-r}$$ – awkward Jun 17 '21 at 14:51
  • awesome. I have memorised the different formulas for combinations and permutations but it's fascinating to see how they actually work. I struggle a bit with the application of it all when there are lots of conditions like at least and at most and combinations of those. I'll get there. Thanks everyone so much for the help. – toby843 Jun 17 '21 at 15:16