Probability of a 4 character code without repetition

  • Thread starter Thread starter scottdave
  • Start date Start date
  • Tags Tags
    Code Probability
Click For Summary

Homework Help Overview

The discussion revolves around calculating the probability of a 4-character code consisting of numbers and letters, specifically focusing on the scenario where only one character is numeric. The subject area includes probability, permutations, and combinations.

Discussion Character

  • Exploratory, Conceptual clarification, Mathematical reasoning, Problem interpretation, Assumption checking

Approaches and Questions Raised

  • Participants explore different methods for calculating the probability, including the use of permutations and combinations. Some question the assumptions about character repetition, while others suggest alternative ways to approach the problem, such as calculating total combinations versus specific cases with one numeric character.

Discussion Status

The discussion is active, with various interpretations being explored. Some participants agree on certain approaches, while others express uncertainty about the calculations. There is no explicit consensus, but several lines of reasoning are being developed and examined.

Contextual Notes

Participants note that the problem specifies no repetition of characters and that the context involves a password rather than a lock. There is also mention of potential discrepancies in the autograder's feedback and the exact wording of the problem statement.

scottdave
Science Advisor
Homework Helper
Insights Author
Messages
2,009
Reaction score
974
Homework Statement
With the high school distance learning, I'm helping my daughter with her 9th grade math problems (probability):
A lock has a 4 "digit" code without repetition. The possible digits are the numbers 0-9, and the letters A,B,C,D,E and F. The question is what is the probability of a code which has only one numeric digit (0-9).
Relevant Equations
Joint Probabilities. Conditional Probability.
The lessons show using Permutations and Combinations for other problems in this section, but we were having difficulty what to choose to put in those formulas. I used this approach:

We have 10 numeric and 6 alphabetic = 16 total possible.
Let's look at the first digit numeric, and the next 3 alpha:
$$ P(First Digit Numeric) = \frac{10}{16} $$ and
## P(Next Digits Alpha) = \frac{6}{15} ## and ## \frac{5}{14} ## and ## \frac{4}{13} ##

Since all four of these have to occur, we multiply them to get ## \frac{1200}{43680} ## which reduces to ## \frac{5}{182} ##

I go through the probabilities for (2nd digit numeric) and then 3rd and 4th, with the same probability for each situation. So we can multiply by 4 to get: ## \frac{20}{182} = \frac{10}{91} ##

This was one of the choices in the multiple choice, but the autograder marked it wrong. I looked it over several times, but come up with the same thing. Then I even programmed a little simulation, and after over 1 million random samples, get nearly the same result. I've known these online homeworks to have mistakes, sometimes, but I wanted to run by here before emailing the teacher.
 
  • Like
Likes   Reactions: PeroK and Delta2
Physics news on Phys.org
In your calculations you have assumed the four characters must all be different, by using 6/15, 5/14 and 4/13 instead of 6/16, 6/16 and 6/16. The problem does not set that requirement, and that is not how most combo locks work.

Instead, first calculate the number of possible combinations, N.
Then calculate the number of different combos that have exactly one numeric character, M.
Then the answer is M / N.
 
  • Like
Likes   Reactions: Delta2
I'll look up about combinations. It's been awhile for me. The question stated that no digit is repeated. That was the way I interpreted it. Oh and the answer key marked 5/182 as the correct choice.
Actually I found the exact wording:
A randomly generated password has four characters. Each character is either A, B, C, D, E or F or a number from 0 - 9. Each character in the password can only be used once. What is the probability that a password has only one number?
OK so it was a password, not a lock.
 
For the problem that you stated, I agree with your answer.
 
Thanks for taking a look, folks. I just wanted to make sure I'm using the proper thinking.
 
Its abit morning here and I haven't drink my coffee and its hard for me to do counting at the moment.

I am thinking of doing it using @andrewkirk approach

AND

it seems to me that the total number of combinations must be much much bigger than the combinations that have only one numeric digit, I sense that the ratio is something like 1/500 or even 1/1000, so between your answer and the book answer I would choose the book answer because it is smaller. SORRY @scottdave !

EDIT: However i am not being able to spot a flaw in your approach, so i don't really know
 
Last edited:
I did some counting now that I drink my coffee and I found the ratio to be (again using Andrew approach)
##\frac{4800}{43320}## which is suprising close to your answer but not exactly the same.
 
Oh I forgot to add 6x5x4x3 (the case the combination are all characters A-F) to the denominator, so my answer coincides with yours.

I think you are correct after all, sorry again @scottdave I was wrong at post #6. o:)

I can post details of the counting if you want me.
 
Last edited:
scottdave said:
Homework Statement:: With the high school distance learning, I'm helping my daughter with her 9th grade math problems (probability):
A lock has a 4 "digit" code without repetition. The possible digits are the numbers 0-9, and the letters A,B,C,D,E and F. The question is what is the probability of a code which has only one numeric digit (0-9).
Relevant Equations:: Joint Probabilities. Conditional Probability.

The lessons show using Permutations and Combinations for other problems in this section, but we were having difficulty what to choose to put in those formulas. I used this approach:

We have 10 numeric and 6 alphabetic = 16 total possible.
Let's look at the first digit numeric, and the next 3 alpha:
$$ P(First Digit Numeric) = \frac{10}{16} $$ and
## P(Next Digits Alpha) = \frac{6}{15} ## and ## \frac{5}{14} ## and ## \frac{4}{13} ##

Since all four of these have to occur, we multiply them to get ## \frac{1200}{43680} ## which reduces to ## \frac{5}{182} ##

I go through the probabilities for (2nd digit numeric) and then 3rd and 4th, with the same probability for each situation. So we can multiply by 4 to get: ## \frac{20}{182} = \frac{10}{91} ##

This was one of the choices in the multiple choice, but the autograder marked it wrong. I looked it over several times, but come up with the same thing. Then I even programmed a little simulation, and after over 1 million random samples, get nearly the same result. I've known these online homeworks to have mistakes, sometimes, but I wanted to run by here before emailing the teacher.

Another idea is to calculate the probabilities for having 0, 1, 2, 3 and 4 numeric digits and check these add to 1.

In many ways it's better to exhaust a problem like this than do one calculation and then move on.
 
  • Like
Likes   Reactions: scottdave
  • #10
scottdave said:
A lock has a 4 "digit" code without repetition. The possible digits are the numbers 0-9, and the letters A,B,C,D,E and F. The question is what is the probability of a code which has only one numeric digit (0-9)

I agree with your answer, without repetition: $$P(\text{1 digit}) = \frac{{6 \choose 3}\times {10\choose 1}}{16\choose 4} = \frac{10}{91}$$
 
  • Like
  • Informative
Likes   Reactions: scottdave and Delta2
  • #11
etotheipi said:
I agree with your answer, without repetition: $$P(\text{1 digit}) = \frac{{6 \choose 3}\times {10\choose 1}}{16\choose 4} = \frac{10}{91}$$
That's nice way of counting (btw I think you should have multiplied both numerator and denominator by 4!, if I understand your reasoning correctly). My way of counting was a bit more complicated and involved taking sums.
 
  • Like
Likes   Reactions: etotheipi
  • #12
Delta2 said:
btw I think you should have multiplied both numerator and denominator by 4!, if I understand your reasoning correctly

In this case, for each unique combination there are 4! permutations, so the proportion of successful combinations to total combinations is equivalent to the proportion of successful permutations to total permutations. So I think either interpretation is permissible.
 
  • Like
Likes   Reactions: Delta2
  • #13
etotheipi said:
I agree with your answer, without repetition: $$P(\text{1 digit}) = \frac{{6 \choose 3}\times {10\choose 1}}{16\choose 4} = \frac{10}{91}$$
Yeah, this helps me understand which numbers should plug into the Combinations formula. Thanks again for the assist. :smile:
 
  • Like
Likes   Reactions: etotheipi
  • #14
I just want to post my way of counting which may be the "less clever" or "brute force" way but I believe still it worth posting to see how we can arrive at the same result as @scottdave in a 3rd way.

So I am following @andrewkirk approach and going to evaluate N and M

M is easy, the combinations of the lock (or passwords) that have numeric digit in the first place and letters in the rest three places are 10x6x5x4 (always without repetition of letters or numerics). They are the same 6x10x5x4 for the numeric in the second place or in the third or fourth place. So it will be
M=4x10x6x5x4=4800

Now we going to evaluate N the number of all possible passwords (with the restriction that no numeric or letter is repeated)
We can see that
N=M+number of passwords with two numerics (in all possible places)+number of passwords with three numerics+number of passwords with 4 numerics+number of passwords with 4 letters=##M+N_2+N_3+N_4+L##

So let's try to evaluate ##N_2##
lets take that the numerics will be in the first two places. Then the number will be 10x9x6x5. But the numerics can be in other two places in general. The number of ways we can choose two places from four maximum places is ##{4 \choose 2}=6##. So it will be
$$N_2={4\choose 2}\times10\times9\times6\times5=16200$$

Thinking in a similar way
$$N_3={4 \choose 3}\times10\times9\times8\times6=17280$$
$$N_4={4 \choose 4}\times10\times9\times8\times7=5040$$

Also it is i believe easy to see that
$$L=6\times5\times4\times3$$

So taking all of the above into a sum we have $$N=4800+16200+17280+5040+360=43680$$

And the ratio is $$\frac{M}{N}=\frac{4800}{43680}=\frac{10}{91}$$
 
Last edited:
  • Love
  • Like
Likes   Reactions: scottdave and etotheipi
  • #15
Delta2 said:
Now we going to evaluate N the number of all possible passwords (with the restriction that no numeric or letter is repeated)
We can see that
N=M+number of passwords with two numerics (in all possible places)+number of passwords with three numerics+number of passwords with 4 numerics+number of passwords with 4 letters=##M+N_2+N_3+N_4+L##
...

So taking all of the above into a sum we have $$N=4800+16200+17280+5040+360=43680$$

And the ratio is $$\frac{M}{N}=\frac{4800}{43680}=\frac{10}{91}$$
Seems to me that finding N doesn't need to be so involved.

We have 16 symbols to choose from and will place one in each of four places without repetition. Then
N = 16×15×14×13 = 43680 .
 
Last edited:
  • Like
Likes   Reactions: ehild and Delta2
  • #16
SammyS said:
Seems to me that finding N doesn't need to be so involved.

We have 16 symbols to choose from and will one in each of four places without repetition. Then
N = 16×15×14×13 = 43680 .
Well what can I say, for this problem you think a lot more cleverly than me :D

My way is dumb and painful but at least it isn't wrong :D
 
  • Like
Likes   Reactions: PeroK
  • #17
I'm glad we were able to hammer this home, multiple ways. Oh did I mention that I ran a random sampling of 1.5 million four-digit codes in Python? I came up within 0.1% of 10/91 probability.
 
  • Like
  • Love
Likes   Reactions: etotheipi and Delta2

Similar threads

  • · Replies 14 ·
Replies
14
Views
3K
  • · Replies 2 ·
Replies
2
Views
3K
Replies
12
Views
4K
  • · Replies 8 ·
Replies
8
Views
2K
  • · Replies 34 ·
2
Replies
34
Views
7K
  • · Replies 13 ·
Replies
13
Views
3K
Replies
7
Views
3K
  • · Replies 11 ·
Replies
11
Views
2K
  • · Replies 14 ·
Replies
14
Views
2K
  • · Replies 5 ·
Replies
5
Views
2K