Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I need to write prolog to find the solution of the following question: 1)You hav

ID: 3823079 • Letter: I

Question

I need to write prolog to find the solution of the following question:

1)You have six colored balls: 4 black, 1 red and 1 blue.

2)There are no more than 2 black balls in a row.

perm2 :- permutationQ([black,black,black,black,red,blue],[A,B,C,D,E,F]),
((A==black -> B==black), (D==black -> E==black);
(C==black -> D==black), (E==black -> F==black));

this is what I thought of so far, are there more ways to go to finish the code? And which letters cannot be Red or Blue??

And I also need to calculate how many solutions exist and the conditions are:

1)Balls with the same color are indistinguishable.

2)All balls are distinct, even those with the same color.

It would be nice with explanations.

Explanation / Answer

The type of arrangements in order to satisfy the given condition are:

BB_BB_

_BB_BB

B_B_BB

BB_B_B

where _ signifies the places filled by balls of other colors.

Let us consider the first condition i.e. Balls with the same color are indistinguishable.

Then each of the 4 above cases can occur in 2 ways

Thus total number of cases is 2x4=8

Let us consider the second condition i.e. All balls are distinct, even those with the same color.

Then each of the above cases can occur in 4!x2 ways (4 black balls can permute among themselves in 4! ways)

Thus total number of cases = 4!x2x4 = 192