# The number of possible passwords under the restriction that letters are more than digits

Good day, I am calculating this problem but I am not entirely sure if it is correct, so I would like to ask for some help.

I need to make a 4 character-long password from either digits or uppercase letters under the restriction that it has more letters than digits and that both can be repeated, and my initial thought is that there are two possible scenarios.

1. 3 letters plus 1 digit
2. 4 letters(no digits)

But I have no idea whether to use the combination formula or permutation formula as I stuck at how to pick 3 or 4 random positions from the password to insert letters, so I would like to ask for some help, thank you

• It depends on whether letters and digits can repeat. Commented Sep 7, 2021 at 17:24
• @MathLover I just updated my question Commented Sep 7, 2021 at 17:26

You have the right scenarios.

Now if there are $$3$$ letters and $$1$$ digit, first choose one of the $$10$$ digits and place it in one of the $$4$$ positions. Each of the rest three positions has choice of $$26$$ letters.

In case of all $$4$$ letters, each position in the password has $$26$$ choices.

Can you take it from here?

• Thank you for answering, but I would still like to gain some insight on using formula to pick 3 random locations to insert the letters because I feel like simply listing all possibilities will not work when it comes to larger input, thank you Commented Sep 7, 2021 at 17:39
• If you read my answer we are not listing all possibilities. ${4 \choose 1}$ picks one of the $4$ places to insert one of the $10$ digits and then $26^3$ to place letters in $3$ remaining places, that is $4 \cdot 10 \cdot 26^3$ permutations for $3$ letters and $1$ digit Commented Sep 7, 2021 at 18:44

HINT: If we denote a letter by L and a digit by D, then the possible patterns for passwords are:

• LLLD
• LLDL
• LDLL
• DLLL
• LLLL

Moreover, there are 26 possible letters and 10 possible digits. Take it from there.

More generally, we can see that if we want an $$n$$-character password with exactly $$d$$ digits, there are exactly $${n \choose d}$$ possible patterns of L's and D's for such a password. One can calculate this for $$0 \leq d \leq \lfloor n/2 \rfloor$$, calculate the number of possible passwords for each such pattern, and then add up all the results. I do not believe there is a more "elegant" answer to this question in general (though I will watch this thread to see if anyone comes up with one.)

• Thank you for answering. My initial attempt was to list all possibilities as well, and it did work for small number, but I would still like to know how to apply the formulas so that I will be able to deal with similar question with a greater range(15 character password probably), thank you Commented Sep 7, 2021 at 17:33
• @Mattmmmmm: I've added a few words about the general case. I don't think there's a particularly elegant way to find the answer in general, though it would be pretty straightforward to write a computer program to calculate it. Commented Sep 7, 2021 at 18:48