In that code you can simply change your "alphabet" (to "YRB") and the length of your "password" (to 5). This will give you ALL the 5-letter combinations of Y, R and B. Then you just have to write a short routine (mine was 6 lines) to check which are valid in the present problem - i.e. contain no more than 5 Y, 3 R and 2 B, which are the ones that you accept and count.
I trust that my interpretation of the problem is correct: one can of paint per wall and the walls are distinguishable.