Probability: bakery distributes pies I'm working through a mathematical statistics textbook, and I can't get a question right. It is a follow-up to this question:

At the end of the day, a bakery gives everything that is unsold to food banks for the needy. If it has 12 apple pies left at the end of a given day, in how many different ways can it distribute these pies among six food banks for the needy?

I think maybe I got this one right (please tell me if it's wrong). Here's what I did:
Every pie can "choose" where to go out of 6 bakeries, with no restrictions, so there are 12 steps each with 6 options, so the total is $6^{12}$. 
Then this is the question I can't answer:

With reference to the previous exercise, in how many different ways can the bakery distribute the 12 apple pies if each of the six food banks is to receive at least one pie?

I thought that I could fix 6 of the pies (so one goes to each bakery) and then distribute the other 6 freely, so the total should be $6^6$ (because there are 6 steps, each with 6 options), but this is wrong. The book has 462 as the answer and I can't figure out why. Help?
 A: Assuming that all of the apple pies are "identical" which really means we only care about how many pies get sent to each food bank (not which pie gets sent where), then the initial problem is a classic stars and bars problem.  You have 12 pies and 6 food banks.  To partition 6 food banks you "need" 7 bars.  I'll illustrate that fact as if we had exactly 6 pies and each food bank received 1 pie:
$$
|*|*|*|*|*|*|
$$
The "in between" for each bar represents what a food bank received (they all received 1 "star", i.e. a pie).  Now we cannot move the first and the last "bar" therefore we actually have five bars and six stars to deal with.  Then we can rearrange them inside however to redistribute the pies.  Of course, you need twelve "stars" between the two outside "bars" thus it becomes a problem of how many ways can we rearrange five bars and twelve stars?
The way we reason through this is that there are $5 + 12 = 17$ stars and bars.  Once we place (in the 17 possible slots) where the bars go, the stars are chosen.  Therefore we say how many different groups of slots can we choose, out of $17$, for $5$ bars or how many different groups of slots can we choose, out of $17$, for $12$ stars?
$$
\binom{17}{5} = \binom{17}{12} = 6188
$$
For the second problem, you simply take out $6$ pies leaving $6$ pies to be distributed among the $6$ food banks.  So now there are still five "bars", but now only six "stars".  Thus we get $5 + 6 = 11$ slots and we choose either to place the 5 bars or the 6 stars:
$$
\binom{11}{5} = \binom{11}{6} = 462
$$
If we are to treat every pie as distinct the problem is much more difficult.  The first is almost easier because, as you said, there are $6$ places to put each pie therefore there are $6^{12}$ permutations.  The second problem is much harder.  First we choose six pies: $\binom{12}{6} = 924$ ways to choose the "first six pies".  Even then, there are $6! = 720$ ways to distribute each of the 924 groups of six pies.  
But the next part becomes quite a bit more difficult.  We can try to extend the stars and bars method.  We again have 6 pies left and there are still only five "bars".  Now when we find that $\binom{11}{5} = 462$ we must multiply by the $6!$ different ways to arrange the remaining 6 pies.
But there are multiple problems with the above approach.  First, if a certain food bank got three pies, then we would severely over count in the above; certainly the order in which they receive the pies doesn't matter but we are counting each different order as a "separate" case.  Another problem is with the initial assumption of choosing the 6 pies to go out.  If we have a scenario where "pie 1" goes to "food bank 1" initially then we later count a permutation where "pie 2" also goes to "food bank 1" this will over count in the case where we initially gave "pie 2" to "food bank 1" and later counted, again, that "pie 1" went to "food bank 1".  So this problem is much more difficult and I'm not sure how you would approach such a problem.
A: First of all, the pies are considered identical so you can't use $12^6$ (or $6^{12}, which would be correct were the pies distinct) because switching some pies does not change the distribution of the pies.
However, these are examples of the well-known Stars and Bars technique, so the answers should be $\binom{17}{5}$ and $\binom{11}{5}$, respectively.
EDIT: To clarify how stars and bars works: For the second example, imagine that the pies are represented by 12 stars: * * * * * * * * * * * *
Now, imagine that a way to divide the pies up corresponds to placing 5 "bars" between the stars to portion them up. For example, giving 3, 4, 1, 1, 1, and 2 pies to the bakeries corresponds to * * *|* * * *|*|*|*|* *
Now, since every bakery gets at least one pie, all bars must be in different "spots." There are 11 spots to put the bars and 5 bars to place so there are $\binom{11}{5}=462$ ways to split the pies.
In general, if you want to split $m$ pies among $n$ bakeries, with the stipulation that each bakery gets at least one pie, there are $\binom{m-1}{n-1}$ ways to do this.
For the first part, you can just imagine adding 6 pies to the mix and adding the stipulation that each bakery gets at least one pie, turning it to an equivalent problem as above. So there are $\binom{18-1}{6-1}=\binom{17}{5}$ ways to do the first part.
A: For the second part, if you assume that pies are not identical, 
apply PIE (ha ha !) 
Unrestricted ways - at least one food bank  left out + at least 2 food banks left out - .....
= $6^{12} - {6\choose 1}\cdot 5^{12} + {6\choose 2}\cdot 4^{12} - ....$
or more compactly, $\sum_{k=0}^5 (-1)^k\cdot {6\choose k}\cdot(6-k)^{12}$
