[Math] Possible 4 character passwords involving a letter and a digit.

combinatoricspermutations

A password consists of 4 characters, each of which is either a digit or a letter of the alphabet. Each password must contain at least ONE digit and AT LEAST ONE letter. How many different such passwords are there?

I am not sure how to go about this one. At first I did 4 blank digits: XXXX. I did lowercase and uppercase separately since it doesn't specify above. 1,679,616 for just digits and lowercase (36^4). 14,776,336 for lowercase, uppercase, and digits (62^4).

There are two different ways I can go about this and I'm not sure which one.

Originally I did 263636*10 (reserved a spot for the digit, and one for the lowercase) and got 336,960 which seems a bit low.

Then I took the total and subtracted it from the things it could not be (10^4 for digits, and 26^4 for letters only) and got 1,212,640.

I essentially did the same with uppercase, but wasn't sure if I should use 26^4 twice (for lowercase and uppercase) or use 52^4.

Which method should I be using, and if possible please explain why?

Thank you!!!

Best Answer

We might as well assume case doesn't matter - if it does, you just need to adjust the numbers slightly. The total number of strings of characters is, as you pointed out, $36^4$. However, not all of these are passwords. If all characters are letters ($26^4$ possibilities) or all characters are numbers ($10^4$ possibilities, none of which doubles up with a case where all characters are letters) then our string is not a password. In all other cases the string IS a password. Hence there are $$36^4-(26^4+10^4)=1\ 212\ 640$$ possible passwords. If the password is case sensitive, the answer becomes $$62^4-(52^4+10^4)=7\ 454\ 720.$$