TITLE: A balls-and-colours problem
QUESTION [21 upvotes]: A box contains n balls coloured 1 to n. Each time you pick two balls from the bin - the first ball and the second ball, both uniformly at random and you paint the second ball with the colour of the first. Then, you put both balls back into the box. What is the expected number of times this needs to be done so that all balls in the box have the same colour?
Answer (Spoiler put through rot13.com): Gur fdhner bs gur dhnagvgl gung vf bar yrff guna a.
Someone asked me this puzzle some four years back. I thought about it on and off but I have not been able to solve it. I was told the answer though and I suspect there may be an elegant solution.
Thanks.

REPLY [2 votes]: Just wish to add some sense to $f(k)$...
Let: 
$X_{i}$ - the number of balls of the color $i$ at time $t=0$. 
$A_{i}$ - the event that in the end all the balls are of the color $i$.
Using this notation:
$E(T|X_{1}=\lambda_{1},\ldots ,X_{n}=\lambda_{n}) =
\sum E(1_{A_{i}}T|X_{1}=\lambda_{1},\ldots,X_{n}=\lambda_{n})$.
But $E(1_{A_{i}}T|X_{1}=\lambda_{1},\ldots,X_{n}=\lambda_{n})$ depends only on $\lambda_{i}$ and is denoted by $f(\lambda_{i})$.
Using "first step" analysis we get:
$E(1_{A_{i}}T|X_{i}=k)=dE(1_{A_{i}}(T+1)|X_{i}=k+1)+
dE(1_{A_{i}}(T+1)|X_{i}=k-1)+(1-2d)E(1_{A_{i}}(T+1)|X_{i}=k)$
where $d=\frac{k(n-k)}{n(n-1)}$
One may compute (using Doob's theorem or otherwise) that $E(1_{A_{i}}|X_{i}=k)=\frac{k}{n}$.
And using that we obtain David Speyer's equation (**) for $f(k)$.