In: Computer Science
A password is a string of ten characters, where each character is a lowercase letter, a digit, or one of the eight special characters !, @, #, $, %, &, (, and ). A password is called awesome, if it contains at least one digit or at least one special character. Determine the number of awesome passwords.
Given,
1. password has 10 characters.
2. Number of lowercase letters = 26
3. Number of Digits = 10
4. Number of special characters = 8
This problem is as example of Inclusion - Exclusion principle.
We have 10 positions. Each of those positions can be occupied by
any of
the 44(26 + 10 + 8) choices available.
Totally we 44 * 44 * 44 * 44 * 44 *44 * 44 * 44 * 44 * 44 = 44^10.
There are 44^10 different passwords possible with given
input.
-------------------------------------------------------------------
Among them is we remove the passwords with NO digit, we get
passwords with
atleast one digit.
If we ignore digits, then total possible choices are 26 + 8 =
34.
We have 10 positions available.
So the passwords with NO digits are = 34^10.
Total passwords with atleast a digit = 44^10 - 34^10 = x (for
easiness)
---------------------------------------------------------------------
Similarly, if we remove the passwords with NO characters, we get
passwords with
atleast one character.
If we ignore characters, then total possible choices are 26 + 10
= 36.
We have 10 positions available.
So the passwords with NO character are = 36^10.
Total passwords with atleast a character = 44^10 - 36^10 = y
(for easiness)
----------------------------------------------------------------------
Total number of passwords possible with atleast one character OR
atleast
one digit = x + y.