Premium problem64. Can the Socks Be Paired?

Medium Locked

A drawer holds black black socks and white white ones. You take k at random without replacement. Return the probability the socks you took can be split into same-colour pairs with nothing left over.

That works out exactly when the number of black socks drawn is even and the number of white ones is too. Sum the hypergeometric probability over the even counts.

Input

black = 5
white = 5
k = 4

Output

0.5238095238095238

Premium problem

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

Implement solve(...)