Number of places in a row where a boy and a girl are standing next to each other. Suppose that $7$ boys and $13$ girls line up in a row. Let $S$ be the number of places in the row where a boy and a girl are standing next to each other. For example,for the row $GBBGGGBGBGGGBGBGGBGG$ we have $S=12$. If all possible orders of these $20$ people are considered,what is the average value of $S$? 
I've been stuck on this problem for the last hours and the only thing I was capable to notice is that if we have a group of $m$ boys and $1$ girl ,then $S=2m/(m+1)$ but then if I add the number of girls the problem becomes much harder...
I know  this s not a big attempt,but it's the only usefull thing I've done...the rest is just about considering small cases to seek for some pattern which isn't necessary to show.
 A: If there are $b$ boys and $g$ girls, then for an individual boy, the expected number of girls on the immediate left is $\dfrac{g}{g+(b-1)+1} =  \dfrac{g}{g+b}$, the number on the right is the same by symmetry, and there are $b$ boys so $$E[S] = \dfrac{2gb}{g+b}$$ which gives $\frac{2 \times 13 \times 7}{13+7}= \frac{91}{10}$ in your example.
A: We make the problem more explicit. Consider positions $2$ to $20$. We say that there is a transition at position $i$ if the people at positions $i-1$ and $i$ are of different sexes. Let $Y$ be the number of transitions. We find $E(Y)$.
We could in principle find the distribution of $Y$, and then find $E(Y)$ in the usual way. That may be very difficult.
Instead, we use the method of indicator random variables. For $i=2$ to $20$, let $X_i=1$ if there is a transition at $i$, and $X_i=0$ otherwise. Then 
$$Y=X_2+X_3+\cdots+X_{20},$$
and by the linearity of expectation
$$E(Y)=E(X_2)+E(X_3)+\cdots+E(X_{20}).$$
Note that by symmetry all the $E(X_i)$ are equal. So it is enough to find $E(X_2)$.
There is a transition at $2$ if we have boy at $1$ and girl at $2$, or the opposite.
The probability of boy at $1$ is $\frac{7}{20}$. Given there is a boy at $1$, the probability of a girl at $2$ is $\frac{13}{19}$, so the probability of a BG transition is $\frac{7}{20}\cdot \frac{13}{19}$. 
Now find the probability of a GB transition at $2$, and finish the calculation. 
