From the picture above I have five slots and a bag of balls (three) of color -red, blue and green...
Now whenever I choose a ball, I note the colour and replace it in the bag, then I randomly keep choosing balls (independent event) until all five slots are filled and put them back in the bag..
How can I derive a formula to find all possible repetitive arrangements (exhaustive approach) with the condition that a MAXIMUM of THREE balls of the same color are in the five slots.
I have ask a similar question at Finding the Total number of permutation using a selective formula
In the accepted answer, there were five slots and five letters and all arrangements with a maximum of three letters were found using a pattern
Now in this question the number of balls and slots varies
I would like to build from the pattern above answer using multinomials (since I don't want to write a new algorithm again)