Probability of a 4 character code without repetition

In summary, the conversation discusses a probability problem involving a 4-digit code with no repeated characters. The question is what is the probability of a code with only one numeric digit. The approach used involves calculating the number of possible combinations and then the number of combinations with only one numeric digit, and then finding the ratio between the two to get the probability. However, there is some disagreement about the correct answer due to differing interpretations of the problem.
  • #1
scottdave
Science Advisor
Homework Helper
Insights Author
Gold Member
1,975
961
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 PeroK and Delta2
Physics news on Phys.org
  • #2
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 Delta2
  • #3
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.
 
  • #4
For the problem that you stated, I agree with your answer.
 
  • #5
Thanks for taking a look, folks. I just wanted to make sure I'm using the proper thinking.
 
  • #6
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:
  • #7
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.
 
  • #8
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:
  • #9
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 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 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 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 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 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 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 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 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 etotheipi and Delta2

1. What is the probability of guessing a 4 character code without repetition?

The probability of guessing a 4 character code without repetition is 1 in 4,320. This means that out of all the possible combinations of 4 characters without repetition, only one will match the correct code.

2. How many possible combinations are there for a 4 character code without repetition?

There are 4,320 possible combinations for a 4 character code without repetition. This is because for each character, there are 26 options (assuming only letters are used), and the number of options decreases by 1 for each subsequent character due to the restriction of no repetition.

3. Is the probability of guessing a 4 character code without repetition affected by the order of the characters?

No, the probability remains the same regardless of the order of the characters. This is because the number of possible combinations is still 4,320 regardless of the order in which the characters are arranged.

4. How does the probability change if the code is longer than 4 characters?

The probability decreases as the length of the code increases. For a 5 character code without repetition, the probability becomes 1 in 118,800. This is because the number of possible combinations increases with each additional character, making it more difficult to guess the correct code.

5. Are there any other factors that can affect the probability of guessing a 4 character code without repetition?

Yes, the probability can also be affected by the number of characters allowed (e.g. if numbers and special characters are also included), the use of a specific pattern or sequence in the code, and the number of attempts allowed. All of these factors can increase or decrease the probability of guessing the correct code.

Similar threads

  • Precalculus Mathematics Homework Help
Replies
2
Views
1K
  • Precalculus Mathematics Homework Help
Replies
14
Views
2K
  • Precalculus Mathematics Homework Help
Replies
12
Views
2K
  • Precalculus Mathematics Homework Help
Replies
8
Views
1K
  • Precalculus Mathematics Homework Help
Replies
34
Views
2K
  • Precalculus Mathematics Homework Help
Replies
7
Views
1K
  • Precalculus Mathematics Homework Help
Replies
14
Views
1K
  • Precalculus Mathematics Homework Help
Replies
11
Views
2K
  • Programming and Computer Science
Replies
1
Views
1K
Replies
4
Views
181
Back
Top