Artificial intelligent assistant

What is the expected value of A? The Happy Animals Kennel has 18 cages in a row. They allocate these cages at random to 6 dogs, 6 cats, and 6 pot-bellied pigs (with one animal per cage). All arrangements are equally likely. Let A be the number of times in the row of cages that two animals of the same species are adjacent. For example, in the arrangement DCPCDPPPDCDPCDCCPD (where D=dog, C=cat, and P=pig), we have A=3. What is the expected value of A? (not sure if expectation is the correct tag here)

The probability that Fido and Rover (two dogs) are in adjacent cages is $$\frac{17}{\binom{18}2}=\frac19,$$ because there are $\binom{18}2$ choices for the (unordered) pair of cages to put them in, and $17$ pairs of adjacent cages.

To get the expected value, multiply this probability by the number of same-species pairs of animals: $$\frac19\cdot3\cdot\binom62=5.$$ The expected value is $5$.

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy 3ad29e657af5059aca994479a19f6e5f