mekhdi wrote:
Hi Team,
I'm reviewing combinators questions. I came to a question that I solved my way and the book solved it another way.
The question is (I changed the names and items a bit):
John is maxing boxes of grapes to give to his friends. He has unlimited supply of 5 different grape colors. If each box has 2 grapes of different colors, how many boxes can he make?
I answered the following:
First grape has 5 options. Second grade has 4 options. In total 5*4 = 20.
Another solution (correct one) for the problem is by anagram YYNNN = 5!/(2!3!)=10
Question 1: So my question is when to answer using the first method and when by the second method?
Question 2: The two solutions differ by a factor of 2. If numbers of grapes in the box change from 2 to 3, the solution will differ by a factor of 6! What's the catch?
Thank you
When you solved the problem the first way, you actually counted all of the boxes twice. To see why, try calling the grapes A, B, C, D, and E. Here are the '5 times 4' options:
A (B, C, D, E)
B (A, C, D, E)
C (A, B, D, E)
D (A, B, C, E)
E (A, B, C, D)
For instance, the first line represents the options AB, AC, AD, AE; the second line represents the options BA, BC, BD, BE; etc.
But, look at that again. We counted AB, and we also counted BA separately. We counted AC (on the first line), but we also counted CA. And so on. You don't actually want to count those options twice, because those aren't actually unique boxes: a box with A and B is the same as a box with B and A.
That's why you need to divide your answer by 2 when you approach it this way: to compensate for the fact that you counted every option twice, instead of just once.
_________________