This is a question I came up with while reading the description of an algorithm for solving a classic puzzle. I'm asking this just to satisfy my own curiosity and maybe learn some useful things from combinatorics.
There's many ways to model the problem, but let's use balls and urns:
Let's say that you have 4 distinguishable urns (let's call them $A$, $B$, $C$ and $D$) and 15 balls of 4 distinguishable types (let's call them $a$, $b$, $c$ and $d$) such that you have 4 balls of each of $(a, b, c)$ and 3 $d$ balls. As you can see, one (natural) way of placing the balls in the urns is putting the four a's in A, the four b's in B, and so on.
So far so good. Now here's the complication I don't know how to deal with: let's assume that the four urns have a fixed capacity to hold a maximum of four balls. So, you can notice that no matter how you divide the balls in the urns, there will always be 3 urns completely full, and one with a single "empty" space.
The question is, how many different ways are there to divide the balls in the urns? There's a number in the URL I referenced in the first paragraph, and I guess I could verify it by writing a program to do it by brute force, but I'd like to know if there's a way to tackle this purely with mathematical reasoning.
In addition, how about if we generalize the problem? Instead of 4 urns, we have $X$ urns, and we have $K$ balls of $X$ types (feel free to assume anything you want for the rest of the details of the general problem).
Edit 1: In case it helps, here's a few more details. As you can gather from the link, this problem is somewhat related to the 15-puzzle. Think of the urns as the rows in the puzzle. Think of the balls as the tiles with the numbers 1 to 15. A "type" of ball represents the row a certain tile belongs to; for example, tiles 1 to 4 belong to row 1 (so they're balls of type $a$), tiles 5 to 8 belong to row 2 (they're balls of type $b$), etc.
The number is in the URL under the section "WK (Walking Distance)", in the paragraph that says "The number of distinct tables is...".
Also, you could certainly represent this as having 5 types of balls, and then you have 16 balls (4 of type $a$, 4 $b$, 4 $c$, 3 $d$ and 1 $e$). The question remains, how many ways are there to put all the balls inside the four urns, considering their capacities?