Premium problem54. Winning a Tennis Game From 30-30

Medium Locked

A player wins each point independently with probability p. From 30-30, which is deuce, they must go two points clear to win. Return their probability of winning the game.

Let WW be the answer. From deuce they either take both points, lose both, or split and return to deuce:

W=p2+2p(1−p)W⇒W=p21−2p(1−p)W = p^2 + 2p(1-p)W \quad\Rightarrow\quad W = \frac{p^2}{1 - 2p(1-p)}

Input

0.5

Output

0.5

Premium problem

This one's part of Premium. Unlock the full Probability track plus every other premium problem on the site.

Implement solve(...)