The simplest aproach for this kind of problem that I am aware of would be to add (X -1) separators to the bunch of Y objects that you want to distribute among X people.
For instance, in your current question, the permutation that looks like OO|O|OO means that Larry got 2 , Michael got 1 and Doug got 2 donuts.
Hence the formula: (Y + X - 1 )! / ( Y! * (X-1)! )
You have to divide by ( Y! * (X-1)! ) since the separators and distributed objects are identical.
So the answer is 7!/(2!*5!) = 21
1) This problem is different, so its approach is different as well. Since each
ball can go to one of X baskets, total number of distributions will be:
X^N
2) This one is a general case of the problem explained in the beginning of this post.
3) I am not sure I understood this question. Please explain.