Chance a random walk hits +a before -b
Your task
A token starts at position 0 on the number line. Each step it moves +1 with probability p and -1 with probability (1-p), where p is given as a float. Return the probability, rounded to 6 decimal places, that the token reaches position +a before it reaches position -b (a and b are positive integers; the walk is absorbed at +a or -b). Constraints: 1 <= a, b <= 1000, 0.0 < p < 1.0.
Examples
reach_a_before_neg_b(a: int, b: int, p: float) -> floatExample 1
Input
reach_a_before_neg_b(1, 1, 0.5)Output
0.5