How many different combinations of $X$ sweaters can we buy if we have $Y$ colors to choose from?
According to my teacher the right way to think about this problem is to think of partitioning $X$ identical objects (sweaters) into $Y$ different categories (colors).
Well,this idea however yields the right answer but I just couldn't convince my self about this way to thinking,to be precise I couldn't link the wording of the problem to this approach,could any body throw some more light on this?
Think of it this way. You go into the shop to buy $X$ sweaters, all identical except for their colors. You know that they come in $Y$ different colors, and you hate to mix colors, so you bring $Y$ shopping bags with you, one for each possible color. Now you pick out your $X$ sweaters and put each one into the bag reserved for its color. You end up with $Y$ shopping bags containing a total of $X$ sweaters, though some of the bags may be empty.
Now suppose that instead of labelling each bag with a color, you label it with a number from $1$ to $Y$. Let $x_1$ be the number of sweaters in bag $1$, $x_2$ the number of sweaters in bag $2$, and so on up to $x_Y$, the number of sweaters in bag $Y$. Then $$x_1 + x_2 + \dots + x_Y = X,\tag{1}$$ and each $x_k$ ($k=1,\dots,Y$) is a non-negative integers. Counting the different ways to choose the sweaters is the same as counting the solutions to $(1)$ in non-negative integers.
Another version of the same problem goes like this: how many ways are there to distribute $X$ identical marbles amongst $Y$ numbered boxes? If $x_k$ is the number of marbles in Box $k$, we are again just counting solutions to $(1)$ in non-negative integers.
This kind of problem is often called a stars and bars problem. Let me explain the solution in terms of the marbles and boxes. Suppose, for the sake of illustration, that $Y=5$ and $X=10$. One possible distribution of the marbles puts $0$ in the first box, $3$ in the second box, $0$ in the third box, $2$ in the fourth box, and $5$ in the fifth box. I can represent this arrangement by a line of ‘stars and bars’: $$|***||**|*****$$
The empty space before the first | represents the empty first box; the three *’s between the first and second |’s represent the three marbles in the second box; and so on. Every possible distribution of the $10$ marbles in the $5$ boxes can be uniquely represented by such a string of $10$ stars and $4$ bars, and each string of $10$ stars and $4$ bars corresponds to a unique distribution of the marbles. Thus, the number of distributions is the number of strings of $10$ stars and $4$ bars. Once you know where the bars are, everything else is a star, so the answer is $\binom{10}{4}$. This of course is also the number of ways of picking out $10$ sweaters of $5$ possible colors and the number of solutions in non-negative integers of $(1)$ when $Y=5$ and $X=10$.
More generally, $Y$ boxes will require $Y-1$ bars to separate them from one another, so you’ll have a string of $X$ stars and $Y-1$ bars, and there are $$\binom{X+Y-1}{Y-1} = \binom{X+Y-1}{X}$$ of these.