In: Advanced Math
This is a Combinatorics Problem
Consider the problem of finding the number of ways to distribute
7 identical pieces of candy to 3 children so that no
child gets more than 4 pieces. Except Stanley (one of the 3
children) has had too much candy already, so he’s only
allowed up to 2 pieces. Write a generating function & use your
generating function to solve this problem.
Suppose there are 3 childrens namely Stanley, A and B.
Here we can give almost 2 candy to Stanley.
Suppose we have given 0 candy to Stanley then we have to distribute 7 candies into A and B so if we give 3 candies to A then we have to give to 4 candies to B vice versa. (2 ways)
Now if we give 1 candy to Stanley then we have to distribute 6 candies in A and B so suppose if we give 4 candies to A to A the we have to give 2 candies to B or vice versa. Or if we give 3 candies to A then we can give 3 candies to B also. So total ( 3 ways) in this case.
Now lastly if we give 2 candies to Stanley then we have remaining 5 candies to distribute in A and B. If we give 4 candies to A then we can give 1 candy to B and vice versa. Similarly if we give 3 candies to A then we can give 2 candies to B and vice versa. So total(4 ways)
So total number of ways are 2+3+4=7 ways we can distribute candies among these 3 children.