All problems
Urn Without Replacement Probability
Problem
An urn has red red balls and blue blue balls. The probability of drawing k reds in a row without replacement is prod_{j=0}^{k-1} (red - j) / (red + blue - j).
Given red, blue, and k (with k <= red), return the probability.
Hint
Multiply the sequential conditional probabilities.
Test cases
case 1
in: [5,5,2]
expected: 0.2222222222222222
case 2
in: [3,1,2]
expected: 0.5
case 3
in: [10,0,3]
expected: 1
Starter codePython
def urn_without_replacement_probability(red, blue, k):
# Your code here
pass3 test cases · run your code against them in the editor