There is a group of five children, where two of the children are twins. In how many ways can I distribute 17 identical pieces of candy to the children, if the twins must get an equal amount of candy?
You can do casework: And the other 3 kids are children, a, b, and c. (STARS AND BARS QUESTION)
1. The twins both get no candy.
a + b + c = 17. Total cases = (17 + 3 - 1) choose (3 - 1) because a and b and c all are nonnegative. 171 total cases.
2. The twins both get 1 candy.
a + b + c = 15. Total cases = (15 + 3 - 1) choose (3 - 1). 17 choose 2 = 136 total cases.
3. The twins both get 2 candies.
a + b + c = 13. Total cases = 15 choose 2. 15 choose 2 = 105 total cases.
4. The twins both get 3 candies.
a + b + c = 11. Total cases = 13 choose 2 = 78 total cases. (You can see the pattern).
In the end, we have 19 choose 2 + 17 choose 2 + 15 choose 2... + 3 choose 2 (this is the each twin gets 8 candies case) = 615 total ways.
A ccomputer code written in C++ gives:
372 ways.
Using combinatorics, we have the following:
1 - Each of the twins receives 0 candies. That leaves: [17 - 1] C [17 - 3] ==120 ways
2 - Each of the twins receives 1 candy. That leaves: [15 - 1] C [15 - 3]==91 ways
3 - Each of the twins receives 2 candies. That leaves: [13 - 1] C [13 - 3]==66 ways
4 - Each of the twins receives 3 candies. That leaves: [11 - 1] C [11 - 3] ==45 ways
5 - Each of the twins receives 4 candies. That leaves: [9 - 1] C [9 - 3] ==28 ways
6 - Each of the twins receives 5 candies. That leaves: [7 - 1] C [7 - 3] ==15 ways
7 - Each of the twins receives 6 candies. That leaves: [5 - 1] C [5 - 3]==6 ways
8 - Each of the twins receives 7 candies. That leaves: [3 - 1] C [3 - 3]==1 way.
Grand Total: 120 + 91 + 66 + 45 + 28 + 15 + 6 + 1==372 ways.