Introduction
Adam (A) and Bubbler (B) are playing coin toss, where the one who wins 5 times first would win the prize of $32. If the game is aborted when the scores are
A:B = 4:3, how should they distribute the prize? Assume the coin toss is fair, so the winning chance of either player is 1/2 for each game.
The answer is:
Adam should take $24 and Bubbler should take $8. Possible cases are as follows:
A wins (score 5:3, chance 1/2): A wins the prize B wins (score 4:4) then A wins (score 5:4, chance 1/4): A wins the prize B wins (score 4:4) then B wins (score 4:5, chance 1/4): B wins the prizeTherefore, the chance of A winning is
3/4and that of B is1/4.
Challenge
In order to do the fair splitting of prizes, we should compute the chance of winning the prize for each player. Given the following information,
X, how many times a player should win coin toss to win the prizeWa, how many times player A has already wonWb, how many times player B has already won
compute the chance of player A winning the prize.
Input and output
You can assume the three input numbers X, Wa, Wb satisfy the following:
- All numbers are non-negative integers.
X > max(Wa, Wb), i.e. the game hasn't finished already.
You can choose to output a fraction or a floating-point number.
Scoring and winning criterion
Standard code-golf rules apply. Shortest code in bytes wins.
Test cases
X Wa Wb => Expected output -------------------------- 5 4 3 => 3/4 = 0.75 5 3 4 => 1/4 = 0.25 1 0 0 => 1/2 = 0.5 4 3 1 => 7/8 = 0.875 4 2 1 => 11/16 = 0.6875 6 4 2 => 13/16 = 0.8125 
WaandWbbe taken as a complex numberWa+j*Wb, wherejis the imaginary unit? \$\endgroup\$6/8instead of3/4? \$\endgroup\$