A house has 10bedrooms and 2 living rooms. 4 rooms can be painted yellow, 5 can be red and 3 purple. The living rooms should be painted different. In how many ways can this be done?

The problem can be solved by counting the number of ways we can fill in the following matrix.

`[;

M=\begin{array}{ccccc} & yellow & red & purple & \sum\ bed & & & & 10\ living & & & & 2\ \sum & 4 & 5 & 3 & \boldsymbol{12} \end{array} ;]`

where [;M_{room,color}\ge 0;] except that the living rooms should be painted different colors. The general problem of counting m x n matrices is not remotely easy. Here, though, you're in luck because you only have to solve three trivial "stars and bars" problems.

  • If you paint the living rooms yellow and purple, then the bedrooms have to satisfy y + r + p = 10, where 0 <= y <= 3, 0 <= r <= 5, and 0 <= p <= 2. There is obviously only one solution to this problem, namely, y = 3, r = 5, and p = 2.

  • If you paint the living rooms red and purple, then the bedrooms have to satisfy y + r + p = 10, where 0<= y <= 4, 0 <= r <= 4, and 0 <= p <= 2. There is obviously only one solution to this problem, too: y = 4, r = 4, and p = 2.

  • If you paint the living rooms yellow and red, then the bedrooms have to satisfy y + r + p = 10, where 0 <= y <= 3, 0 <= r <= 5, and 0 <= p <= 3. This problem is more complicated because you have more paint than you need, but only slightly more complicated because you only have 1 application of paint more than you need. If you use less purple, then there is only one solution: p = 3, y = 3, r = 4. If you use less red, then the solution is r = 4, y = 3, p = 3. And if you use less yellow, then y = 2, r = 5, p = 3.

Each solution excludes the others, therefore there are 1 + 1 + 3 = 5 ways to paint all the rooms.

/r/probabilitytheory Thread