At ReallyUnsecurePassword.com, they demand that users have a password, which consists of the digits from 0 to 9, and is of length 4 that uses exactly 2 different digits. How many different passwords can there be?
Details and assumptions
0 0 0 1 is a valid password, while 3 3 3 3 and 0 1 2 3 are not valid passwords because they do not use exactly 2 different digits.
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
⌣ ¨
First, we must select two distinct digits to use. There are ( 2 1 0 ) = 4 5 ways to do this. Then, there are three ways in which we can arrange them. Let the digits be X and Y.
Case 1 : Permutations of XXXY. Given X and Y, there are ( 3 4 ) = 4 such permutations.
Case 2 : Permutations of XXYY. Given X and Y, there are ( 2 4 ) = 6 such permutations.
Case 3 : Permutations of XYYY. Same reasoning as Case 1. By symmetry, we have 4 permutations here as well.
Thus, our answer is 4 5 ⋅ ( 4 + 6 + 4 ) = 4 5 ⋅ 1 4 = 6 3 0 .
Shouldn't you tell in your solution as to why are we adding 4 , 6 and 4 , instead of multiplying them?
Initially we need to select 2 digits from the 10 digits. The number of ways to select those two digits is ( 2 1 0 ) , which is equal to 45.
Now, we need arrange those two digits such that both the digits should come at least once. Total number of numbers that can be made using 2 digits (let us say a and b) with repetition is 2 4 = 1 6 , out of which we need to remove two numbers of the form aaaa and bbbb. Therefore they are 16 - 2 = 14 ways to use both digits.
By the product rule, the total number passwords possible is 4 5 × 1 4 = 6 3 0 .
First, we select our two different digits. From the set of 10 possible digits, there are ( 2 1 0 ) = 4 5 to select the two digits. Now, we must consider how many times that digit appears in the password. Since both digits have to present, a digit can appear between 1 to 3 times. If one digit appears once, then the other digit appears 3 times, and there are ( 1 4 ) ways to order these digits to make different passwords. Similarly, we have ( 2 4 ) and ( 3 4 ) for the other frequency of repeats. Given two digits, then, we have ( 1 4 ) + ( 2 4 ) + ( 3 4 ) = 1 4 ways to order the digits to make distinct passwords. Thus, the total number of passwords is 4 5 ∗ 1 4 = 6 3 0 .
Let's call the two different digits a and the other b. We have two cases:
1) One digit occurs once, and the other three times; 2) The digits occur twice each.
In case 1, call the single digit a, and the other b. a can occur in four different places, so given a and b, there are four different passwords.
In case 2, call the first digit a. There are three different combinations: aabb, abab and abba. So given a and b, there are three different passwords.
Altogether, for each selection of a and b out of the digits 0 to 9, there are seven passwords. The number of ways to select two different digits a and b is 10 9. (a and b are distinguished, since they have different roles in both cases above, so we don't do the division of 2 that we would do if we wanted two digits in any order.) 10 9*7 = 630.
The first digit has 10 possibilites, and then it can be split into 3 cases. For the first case, the second digit differs from the first, there are 9 possibilities, and then 2 each for the remaining digits, so 10 9 2 2 possible passwords. In the second case, the second digit is the same as the first and the third digit differs, and the last again has 2 possibilites, so 10 1 9 2 possible passwords. For the last case the first three digits could all be identical and the last different, so 10 1 1*9 possible passwords. Add these three cases up for the total number of different passwords.
let the digits be A and B. the combination of A and B is 10C2 = 45. the permutation of 3A 1B = 4!/3! = 4; 2A 2B = 4!/(2!2!) = 6; and 1A 3B same as 3A 1B = 4. so all together 14. so the number of passwords = 45*14 = 630
1st case, whereby the number can be 0001 (3 similar digits and one distinct). there is a total of 10x9x4 = 360 numbers, whereby 10 indicates the possible digits for the digit repeated three times, 9 possible digits for the single digit and 4 is the number of ways you can rearrange it (4C1).
2nd case, whereby the number can be 0011 (2 distinct digits repeated twice) there is a total of 3x9x10 = 270 numbers, whereby 10 and 9 indicates the possible digits and 3 is the number of ways to rearrange them.
Total number of passwords would be 270+360= 630
We either have 3 of one digit and 1 of the other, or 2 of each.
If we have 3 of 1, and 1 of the other, then:
There are 10 ways to choose the digit used three times, there are 9 ways to choose the digit used once, and there are ( 1 4 ) = 4 ways to arrange them. This gives 1 0 ⋅ 9 ⋅ 4 = 3 6 0 passwords.
If we have 2 of each, then:
There are ( 2 1 0 ) = 4 5 ways to choose the digits, and ( 2 4 ) = 6 ways to arrange them. This gives 4 5 ⋅ 6 = 2 7 0 passwords.
The answer is 3 6 0 + 2 7 0 = 6 3 0 .
First we select two numbers from [0,9] inclusive which can be done in 10C2=45 ways..
Now that we have 2 numbers we are to place these in the 4 places. We can do this by 2^4 ways but that includes all of the same type for bot the numbers
Thus answer is 45*(16-2) == 630
TYPO end of line 4 -for BOTH the-
Let the digits in the password be x1, x2, x3 and x4.
x1 can be chosen in 10 ways(0, 1, ...., 9).
Case 1: x2=x1. Then x2 can be chosen in 1 way.
Subcase 1a: x3=x1. Then x3 can be chosen in 1 way and x4 can be chosen in 9 ways (0, 1, ...., (x1)-1, (x1)+1, ..., 9).
Subcase 1b: x3!=x1. Then x3 can be chosen in 9 ways (0, 1, ...., (x1)-1, (x1)+1, ..., 9) and x4 can be chosen in 2 ways (x1, x3).
Case 2: x2 != x1. Then x2 can be chosen in 9 ways (0, 1, ...., (x1)-1, (x1)+1, ..., 9), x3 can be chosen in 2 ways (x1, x2) and x4 can be chosen in 2 ways (x1, x2).
Thus total number of ways is
(10 X 1 X 1 X 9 (for case 1a))
+ (10 X 1 X 9 X 2 (for case 1b))
+ (10 X 9 X 2 X 2 (for case 2))
= (90 + 180 + 360)
= 630
First we need to chose 2 digits from 0 to 9. we can do that by ( 2 1 0 ) = 4 5 ( 1 )
Now we need to find the number of combinations we can write one of those (for example 3 and 7 )
3 3 3 7 , 3 3 7 3 , . . . , 7 7 7 3
There are 2 4 − 2 = 1 4 ( 2 ) of these numbers.
To get the result we multiply ( 1 ) and ( 2 ) and get 630
How did you get that there are 2 4 − 2 = 1 4 of these numbers? Process?
Let a be the one of the 2 distinct digits and b be the other. Notice that there will be 2 types of passwords that fulfills the given conditions (in the question).
1 s t type: There are 2 a , 2 b in the password, meaning that the distinct digits a and b occur twice each. The number of ways to arrange the 2 a and 2 b = 2 ! × 2 ! 4 ! . Since there are 1 0 digits from 0 to 9, the number of ways to choose a = ( 1 1 0 ) = 1 0 . Also since a = b , the number of ways to choose b = ( 1 1 0 − 1 ) = 9 . Note that when choosing for a and b , there is a repeated case for every pair of a and b chosen: for example, choosing a = 4 and b = 6 is equal to a = 6 and b = 4 since both a and b appears twice in the password. Therefore, the number of the 1 s t type of password = 2 2 ! × 2 ! 4 ! ( 1 1 0 ) ( 1 1 0 − 1 ) = 2 7 0 .
2 n d type: There are 3 a , b in the password. Similarly, there are ( 1 1 0 ) ways to choose a and ( 1 9 ) to choose b . The number of ways to arrange the 4 numbers = 3 ! 4 ! = 4 . Note that there is no need to divide by 2 here as the number of a s and b s in the password is different. Therefore, number of possible 2 n d type password = 3 ! 4 ! ( 1 1 0 ) ( 1 9 ) = 3 6 0 .
Hence, the total number of different passwords there can be that satisfy the given conditions = 2 7 0 + 3 6 0 = 6 3 0
First, select which two distinct digits do you plan to use for your password. Thus from a pool of 10 digits, you select two (say a and b ).
C(10,2) = 45
Then, you have 3 possible combinations of the 2 digits a and b :
3 of a + 1 of b
2 of a + 2 of b
1 of a + 3 of b
In these three cases, use permutation (with objects alike) to determine their positions:
4!/(3!1!) = 4
4!/(2!2!) = 6
4!/(1!3!) = 4
Then,
C(10,2) x 4 + 6 + 4 = 630
Of the digits from 0 to 9, there are ( 2 1 0 ) ways to choose a combination of 2 digits a and b . There are 2 4 ways to create a password of length 4 consisting of a and b , however we need to remove 2 cases, aaaa and bbbb . The number of different passwords is ( 2 1 0 ) ( 2 4 − 2 ) = 6 3 0 .
There is 10 choose 2 ways to select 2 different digits. (4 choose 1) + (4 choose 2) + (4 choose 3) ways to arrange these two different digits. multiply these to obtain 630
= 10C2 * ( (4P1/3!) + ( 4P2/(2!*2!) + (4P3/3!) ) ) = 10 * 9 * ( 4 + 6 + 4) = 630
First, it is obvious that there are 10C2 = 45 possible pairs of digits. As for the order of digits, we can first assume that each character is either one digit (A) or the other (B), yielding 2^4 = 16 digits for each pair. But this includes AAAA and BBBB which are not applicable as there is only one digit, leaving us with 16-2 = 14 permutations for each pair. Hence there are 45 x 14 = 630 different passwords.
There are 14 ways to write a 4 digit password from any 2 given numbers.
-aaab
-aaba
-aabb
-abaa
-abab
-abba
-abbb
-baaa
-baab
-baba
-babb
-bbaa
-bbab
-bbba
Now, there are 2-P 10 ways to chose 2 digits without repetition from ten digits. 2P 10 = \frac {10 \times 9}{2} =45 Therefore, the required number is 45 \times 14 = 630
I think in code
def padWithZeros(strNumber):
while len(strNumber)!=4:
strNumber = '0' + strNumber
return strNumber
def has2DifferentDigits(number):
strNumber = padWithZeros(str(number))
foundDigits={}
for c in strNumber:
if not foundDigits.has_key(c):
foundDigits[c] = 1
return len(foundDigits.keys()) == 2
validPasswordsFound = 0
for i in xrange(10000):
if has2DifferentDigits(i):
validPasswordsFound = validPasswordsFound + 1
print "Found",validPasswordsFound," =>", padWithZeros(str(i))
...
Found 630 => 9998
First part of the problem is to picking two distinct numbers from the total possible of 10.
That is: C ( 1 0 , 2 ) = 2 1 0 × 9 = 4 5
Second part of the problem is to calculate how many different ways these two could come together to form the password. Let's say A is the first number and B is the second one. There are three different categories: 3 A's and 1 B (like AABA), 2 A's and 2 B's (like AABB) and 1 A and 3 B's (like BABB)
3 A 1 B : C ( 4 , 1 ) = 4 which is also the case for 1 A 3 B 2 A 2 B : C ( 4 , 2 ) = 2 4 × 3 = 6 total is: 4 + 4 + 6 = 1 4
Which means there are 4 5 × 1 4 = 6 3 0 different passwords
Problem Loading...
Note Loading...
Set Loading...
Let the digits be a and b , and the password a x x x . There are 2 3 − 1 = 7 ways to fill in the last 3 digits, with a a a a invalid. there are 1 0 possibilities for a , and 9 for b , so there are 7 ⋅ 9 ⋅ 1 0 = 6 3 0 total passwords. ⌣ ¨