Black and white balls in separate boxes rounds until all moved I would like to ask, if I have for example a box with 4 white balls and a box with 4 black balls and each time I draw a ball from each box and put it in the other at the same time for the 2 boxes, after how many rounds will all the black balls have been transferred to the box containing initially the white balls?
Thank you!
 A: Let $f(i)$ be the expected number of moves required to end up with all the black balls in the white box, where $i$ is the number of black balls already in the white box.  We seek $f(0)$.
We know $f(4) = 0$, since $i=4$ implies all the black balls are in the white box, and we're done.
For $i=3$, if we make $1$ switch, we have a $1/16$ chance of moving to $i=4$ ($1/4$ to pick the one remaining white ball and $1/4$ to pick the one remaining black ball).  Also, there is a $6/16$ chance to remain at $i=3$ and a $9/16$ chance to change to $i=2$.  Thus, the average number of switches to get from $i=3$ to $i=4$ is $1$ plus the weighted average of the result states:
$$ f(3) = 1 + {9\over 16} f(2) + {6\over 16} f(3) + {1\over 16} f(4)$$
Similarly,
$$ f(2) = 1 + {1\over 4} f(1) + {1\over 2} f(2) + {1\over 4} f(3)$$
$$ f(1) = 1 + {1\over 16} f(0) + {6\over 16} f(1) + {9\over 16} f(2)$$
$$ f(0) = 1 + f(1)$$
If you substitute in $f(4) = 0$, you can solve for $f(3)$ in terms of $f(2)$.  Substitute that into the formula for $f(2)$, and you can solve for $f(2)$ in terms of $f(1)$.  Substitute that into the formula for $f(1)$ and you can solve for that in terms of $f(0)$.  Then substitute that into the final formula, and you can calculate $f(0)$.
To get you started,
$$ f(3) = 1 + {9\over 16} f(2) + {6\over 16} f(3)$$
$$ {10\over 16} f(3) = 1 + {9\over 16} f(2)$$
$$ f(3) = 1.6 + {9\over 10} f(2)$$
Repeat the substitutions until you get $f(0)$.  That's your answer for the average time it'll take to get all the black and white balls switched.
