Problem in Counting - Number of Passwords

  • Context: High School 
  • Thread starter Thread starter SamitC
  • Start date Start date
  • Tags Tags
    Counting
Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
11 replies · 2K views
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?
 
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...
 
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   Reactions: SamitC and BvU
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   Reactions: 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:
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.)
 
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.