• + 1 comment

    this is really just math so sit down with pen and pencil and figure it out.

    In case you need some hints, consider this relation:

    expectedTime cntPoped cntUnpoped =
       (cntPoped / (cntPoped + cntUnpoped)) * (1 + expectedTime cntPoped cntUnpoped)
       + (cntUnpoped / (cntPoped + cntUnpoped)) * (1 + expectedTime (cntPoped + 1) (cntUnpoped - 1))
    

    now of course this will not work as the recursion never stops - here comes the math (solve x = a*(1+x) + y for x and compare)

    the rest should be really easy