# How does this solution involve counting surjective functions?

I recently had the following question, which I answered incorrectly, in a combinatorics exam:

How many ways are there to put 8 balls in 9 holes $H_1, ..., H_9$ if the balls are all different and only the holes $H_1, H_2, H_3, H_4$ are empty?

Apparently, the solution is:

$$5!S(8,5)$$

Where $S(8,5)$ is the Stirling number. In effect, the solution is the number of surjective functions from the set of cardinality 8 to the set of cardinality 5.

Is someone able to explain this solution to me? From my understanding, if we know that $H_1, H_2, H_3, H_4$ are all empty, it's simply a matter of assigning 8 balls to the 4 holes. The question doesn't state anything about a hole containing at least one ball.

• I'm confused as well. If a hole can contain more than one ball, why does the question say anything about holes previously being empty or not empty? Perhaps because the goal is to count how many configurations of possibly-multiple-balls-in-holes there are - but then, wouldn't we also need to know how many balls are currently in the non-empty holes? On the other hand, if a hole cannot contain more than one ball, why would the exam bother stating the problem with obviously useless information? (Non-obviously useless information would be understandable.) Jun 20 '15 at 5:55
• @Zev: The problem is to count the ways to distribute the $8$ balls amongst the $9$ holes in such a way that precisely the first $4$ holes are empty. Jun 20 '15 at 5:58
• @Brian: That's an interpretation that explains the given answer, but I'd have to consider it a poorly-worded question if that is the intended meaning. Jun 20 '15 at 5:59
• @Zev: It certainly wins no prizes for clarity. Jun 20 '15 at 6:01
• It is not that the question is not clear (my guess that the final "are empty" should be read "are to remain empty" seems right), it is just slightly weird. Why would one want to introduce the first four holes only to then require that they remain unused? It seems like the only reason is to better hide the fact that the phrase "only the holes ..." also requires the other holes not to remain empty. Jun 20 '15 at 6:07