Find all possible combinations given a certain criteria

dxoo

New member
Joined
Jul 16, 2020
Messages
15
The problem statement is as follows:

James has forgotten the number combination of his locker. The combination is a five-digit number, each digit being {0, 1, 2, 3, 4, 5}. All he can remember is:
  1. The first three digits add to 4
  2. The fifth digit is greater than the fourth
Knowing only this information, how many combinations are there if repetition of digits are allowed?
 
The problem statement is as follows:

James has forgotten the number combination of his locker. The combination is a five-digit number, each digit being {0, 1, 2, 3, 4, 5}. All he can remember is:
  1. The first three digits add to 4
  2. The fifth digit is greater than the fourth
Knowing only this information, how many combinations are there if repetition of digits are allowed?

I'd suggest you start by trying to list all possibilities for the first three digits. If the number gets large enough there are ways to just count them, instead, but that may not be necessary.

Keep in mind that we want to see your work before we can help much, because we want to guide you to think for yourself:
 
I'd suggest you start by trying to list all possibilities for the first three digits. If the number gets large enough there are ways to just count them, instead, but that may not be necessary.

Keep in mind that we want to see your work before we can help much, because we want to guide you to think for yourself:

Got it, Doc! Your idea helped me identify a pattern which led me to the solution. I broke up my solution in two ways: a naive solution and a more "mathematically sound" solution. I guess I'm answering my own solution but I hope this post is helpful!

Naive Solution:
I got 15 possibilities for the first 3 digits (I think I got all of them)

0 0 4
0 4 0
0 1 3
0 3 1
0 2 2

1 3 0
1 0 3
1 1 2
1 2 1

2 0 2
2 2 0
2 1 1

3 1 0
3 0 1

4 0 0

I counted there to be 15 possibilities for the last two digits, assuming the last digit must be strictly greater than the fourth.

0 1
0 2
0 3
0 4
0 5

1 2
1 3
1 4
1 5

2 3
2 4
2 5

3 4
3 5

4 5

Since there are 15 possibilities for the first three digits and 15 possibilities for the last two digits. The answer's simply: 15*15 = 225

More "Mathematically Sound" Solution:
You may notice in the pattern while listing out the first three digits and while listing the final two digits. When the first digit is 0 there are 5 possibilities; when the first digit is 1 there are 4 possibilities; when the first digit is 2 there are 3 possibilities... So we can deduce there are 15 combinations without even writing them all out because we observed a pattern. 5+4+3+2+1=15. We can use this same reasoning to deduce there are 15 combinations of the last two digits. So without even listing the possibilities, which is a very tedious and mistake-prone process we know there are 15 combinations of the first three digits and 15 combinations for the final two digits. So for every combination of the first three digits, we multiply it by the 15 combinations of the final two digits to arrive at 15*15=225!

Although you may not know where to start when you first see a problem, it helps by writing out a naive approach since you can often identify things that can make your approach more efficient. Also, try to be as observant as possible, it might help! This is my first post on this site, and I hope this post was helpful.
 
The problem statement is as follows: James has forgotten the number combination of his locker. The combination is a five-digit number, each digit being {0, 1, 2, 3, 4, 5}. All he can remember is:
The first three digits add to 4
The fifth digit is greater than the fourth
Knowing only this information, how many combinations are there if repetition of digits are allowed?
Look at this expansion. The term \(15x^4\) in it tells us that there are fifteen ways for the first three numbers to add to four.
The list two digits in which the first is less that the second yields fifteen ways.
Using these facts there are thirty possible combinations meeting the possible code.
 
Look at this expansion. The term \(15x^4\) in it tells us that there are fifteen ways for the first three numbers to add to four.
The list two digits in which the first is less that the second yields fifteen ways.
Using these facts there are thirty possible combinations meeting the possible code.

Shouldn't then the answer be 225 since 15*15 = 225? Could you please clarify how you got 30 as opposed to 225?
 
Got it, Doc! Your idea helped me identify a pattern which led me to the solution. I broke up my solution in two ways: a naive solution and a more "mathematically sound" solution. I guess I'm answering my own solution but I hope this post is helpful!

Naive Solution:
I got 15 possibilities for the first 3 digits (I think I got all of them)

0 0 4
0 4 0
0 1 3
0 3 1
0 2 2

1 3 0
1 0 3
1 1 2
1 2 1

2 0 2
2 2 0
2 1 1

3 1 0
3 0 1

4 0 0

I counted there to be 15 possibilities for the last two digits, assuming the last digit must be strictly greater than the fourth.

0 1
0 2
0 3
0 4
0 5

1 2
1 3
1 4
1 5

2 3
2 4
2 5

3 4
3 5

4 5

Since there are 15 possibilities for the first three digits and 15 possibilities for the last two digits. The answer's simply: 15*15 = 225

More "Mathematically Sound" Solution:
You may notice in the pattern while listing out the first three digits and while listing the final two digits. When the first digit is 0 there are 5 possibilities; when the first digit is 1 there are 4 possibilities; when the first digit is 2 there are 3 possibilities... So we can deduce there are 15 combinations without even writing them all out because we observed a pattern. 5+4+3+2+1=15. We can use this same reasoning to deduce there are 15 combinations of the last two digits. So without even listing the possibilities, which is a very tedious and mistake-prone process we know there are 15 combinations of the first three digits and 15 combinations for the final two digits. So for every combination of the first three digits, we multiply it by the 15 combinations of the final two digits to arrive at 15*15=225!

Although you may not know where to start when you first see a problem, it helps by writing out a naive approach since you can often identify things that can make your approach more efficient. Also, try to be as observant as possible, it might help! This is my first post on this site, and I hope this post was helpful.
Good work. What you did is just about what I was hoping you'd do: both a brute force enumeration and a more thoughtful calculation based on what you learned, which would be more necessary with larger numbers. Often if you just start the long way and can't finish it, you discover things that can be useful in finding a more efficient solution.

Now I'll show how I would have done the details (if the numbers were large enough that I needed "power tools"):

A sum of three numbers 0 through 4, whose sum is 4, can be thought of as putting bars between stars, like 1+0+3 = *| |***. This amounts to arranging 4 stars and 2 bars, or choosing 2 places out of 6 for the bars: C(6,2) = (6*5)/(2*1) = 15.​
Two different numbers 0 through 5 arranged in ascending order is a combination of 2 out of 6 digits (that is, putting them in a fixed order is equivalent to saying order doesn't matter in the choice). So we have C(6,2) again, another 15.​

And, yes, you are right to multiply. pka used a very powerful tool that can cut your fingers off it you aren't careful ...
 
Good work. What you did is just about what I was hoping you'd do: both a brute force enumeration and a more thoughtful calculation based on what you learned, which would be more necessary with larger numbers. Often if you just start the long way and can't finish it, you discover things that can be useful in finding a more efficient solution.

Now I'll show how I would have done the details (if the numbers were large enough that I needed "power tools"):

A sum of three numbers 0 through 4, whose sum is 4, can be thought of as putting bars between stars, like 1+0+3 = *| |***. This amounts to arranging 4 stars and 2 bars, or choosing 2 places out of 6 for the bars: C(6,2) = (6*5)/(2*1) = 15.​
Two different numbers 0 through 5 arranged in ascending order is a combination of 2 out of 6 digits (that is, putting them in a fixed order is equivalent to saying order doesn't matter in the choice). So we have C(6,2) again, another 15.​

And, yes, you are right to multiply. pka used a very powerful tool that can cut your fingers off it you aren't careful ...


Thanks, for the insight! Your replies were very helpful :)
 
Top