B Problem in Counting - Number of Passwords

  • B
  • Thread starter Thread starter SamitC
  • Start date Start date
  • Tags Tags
    Counting
AI Thread Summary
The discussion revolves around calculating the number of valid passwords with 6 to 8 characters, including at least one digit, while considering the role of blanks. The original book method calculates passwords as P6 = 36^6 − 26^6 for 6 characters, resulting in 1,867,866,560, and similarly for 7 and 8 characters, totaling 2,684,483,063,360. An alternative approach suggests including blanks, leading to different calculations, but raises questions about the validity of blanks in passwords. Participants clarify that blanks should not count as characters in the context of valid passwords, emphasizing that the book's definition is paramount. The final consensus indicates that the book's method is the accepted standard for this problem.
SamitC
Messages
36
Reaction score
0
Problem: How many passwords can be created with 6 to 8 characters. Letter case does not matter. Every password must have at least 1 digit.

Approach taken in the solution in the book:
Passwords with 6 characters P6 = 36^6 − 26^6 = 1,867,866,560.
Similarly, we have P7 = 36^7 − 26^7 = 70,332,353,920
and P8 = 36^8 − 26^8 = 2,612,282,842,880.
So, Answer: P = P6 + P7 + P8 = 2,684,483,063,360

My approach:
(number of passwords possible with 6 characters) * (adding 7th an 8th characters including blank) - (number of passwords possible with 6 alpha) * (adding 7th an 8th alpha including blank)

36^6 * 37^2 - 26^6 * 27^2 = 2,754,815,417,280

The answers are different. Can you pls. help finding what did I miss?
 
Physics news on Phys.org
I don't think blanks count as characters ... would your exercise (or your computer, for that matter) accept a ##1## plus six spaces as password ?
[edit] ah, see what you mean with these blanks. But adding two blanks to 6 letters doesn't work...
 
One has ##36^8 + 36^7 + 36^6 - 26^8 - 26^7 - 26^6##, the other has ##36^6 * 37 * 37 - 26^6 * 27*27##
 
BvU said:
[edit] ah, see what you mean with these blanks. But adding two blanks to 6 letters doesn't work...
That's actually okay. adding two blanks to a 6 letter password gives a 6 letter password, and we should count that.
The problem is adding blank+letter or letter+blank. only one of these cases produces a valid password.
 
  • Like
Likes SamitC and BvU
SamitC said:
Every password must have at least 1 digit.
[edit] shoot, it gets counted in and then subtracted, my bad.
 
  • Like
Likes SamitC
willem2 said:
The problem is adding blank+letter or letter+blank. only one of these cases produces a valid password.

Can you pls. explain more on this? I did not understand the blank+letter or letter+blank concept.
As per my understanding, blank is nothing. So if two blanks remain anywhere in a 7 character word, it becomes a 5 character word. i.e. does not matter where blank remains but what matters is how many times we allow blanks. Pls. correct me if wrong.
 
SamitC said:
Can you pls. explain more on this? I did not understand the blank+letter or letter+blank concept.
As per my understanding, blank is nothing. So if two blanks remain anywhere in a 7 character word, it becomes a 5 character word. i.e. does not matter where blank remains but what matters is how many times we allow blanks. Pls. correct me if wrong.

It seems I can't use the blanks. If the last two digits are blank then it means 6 character password which is already counted. Now, 7th or 8th char being blank means the same thing - 7 character password.
Now I am asking to myself - can we solve this problem using the blanks as characters with additional logic?
 
SamitC said:
It seems I can't use the blanks. If the last two digits are blank then it means 6 character password which is already counted. Now, 7th or 8th char being blank means the same thing - 7 character password.
Now I am asking to myself - can we solve this problem using the blanks as characters with additional logic?
You will have to count the cases with 0, 1 and 2 blanks separately.
There's one combination with 2 blanks, 36 with 1 character + a blank, and 362 with 2 characters.
You will get 366(1 + 36 + 362) which is the same as with the other method.
 
  • Like
Likes SamitC and BvU
It's important to state that it doesn't matter what we think is a valid password. The OP asks about the book answer, so the only thing that counts is what the book thinks. Without more information from the book, one is fishing for a set of rules that will match the book calculations.

From the book calculations, a blank is not valid anywhere. It's just the total number of possibilities from {a..z,0..9} (= 366) minus the total number of all-non-digit possibilities from {a..z} (=266) That is for 6 character passwords. The final answer is the sum of the answers for 6, 7, and 8 character passwords, similarly defined.
 
Last edited:
  • #10
Beg to differ. You would get 1 867 866 560 which is not the book answer
 
  • #11
BvU said:
Beg to differ. You would get 1 867 866 560 which is not the book answer
That is the book answer for 6 characters. It is summed with the corresponding answers for 7 and 8 characters. So the book's approach and definition of what is a valid password seems clear. (After seeing your response, I added another line to post #9.)
 
  • #12
SamitC said:
It seems I can't use the blanks. If the last two digits are blank then it means 6 character password which is already counted. Now, 7th or 8th char being blank means the same thing - 7 character password.
Now I am asking to myself - can we solve this problem using the blanks as characters with additional logic?
If you are allowing blanks, you would have to specify the rules you want to follow for a legitimate password with blanks. If you do not want to count trailing blanks the logic will change, but if you just want to allow a blank like any other non-digit character, then change all the book calculation 36's and 26's to 37 and 27, respectively:
6 characters = 376-276 = 2,178,305,920
7 characters = 377-277 = 84,471,523,930
8 characters = 378-278 = 3,230,049,917,440
Total of 6, 7, or 8 characters = 3,316,699,747,290

PS. I don't see why many password programs wouldn't use trailing blanks as part of the password.
 
Back
Top