Help me with the logic

How to approach this problem, can please help me with the logic.Thnx

@aryan
Fill n spaces , with k colors. First select k spaces with k-different color. Now we are left with n-k spaces ,which can be filled with any of the k colors. Now to fill m-spaces by r-color with each r is infinte amount,we do thisā€¦

Using a method thatā€™s often called ā€œstars and barsā€: We draw n stars in a row to represent the cakes, and kāˆ’1 bars to divide them up. All of the stars to the left of the first bar are cakes of the first type; stars between the first two bars are of the second type;

| || | Hereā€™s an example with n=6 and k=5. Weā€™re getting 2 of the first type, 3 of the second type, 0 of the third type, 1 of the fourth type, and 0 of the fifth type. In order to solve the problem, we just need to reorder the stars and bars by choosing the kāˆ’1 spots for the bars out of the n+kāˆ’1 total spots, so our answer is:

(n-1)C(k-1) = C(n-1,k-1)

hope its clear if yes dont forget to hit like and mark resolved :smiley: