Hacker News new | ask | show | jobs
by barbegal 2223 days ago
> Like all such problems the actual answer is obvious once you realize it or if you already know it.

I believe this problem is really trying to get you to formulate an abstract problem mathematically. It's not a trick question, it can be solved with math.

In this problem we can start with all 10 marbles in one bag (bag A). We have two degrees of freedom: how many black marbles to put in the other bag (bag B) (call this variable b) and how many white marbles to put in the other bag (call this variable w).

0 <= b <= 5

0 <= w <= 5

1 <= b + w <= 9 (can't have everything in one bag)

These three constraints form a hexagon.

Probability of picking black from bag A: (5-b)/(10-b-w)

Probability of picking black from bag B: b/(b+w)

Probability of picking black given probability of picking bag A = 0.5: 0.5((5-b)/(10-b-w)) + 0.5(b/(b+w))

Now we know that the problem has two symmetries, bag A vs bag B (b = w) and white vs black (b+w = 5) so our hexagonal solution space must also be symmetric with probability = 0.5 along those lines. This leaves just 6 points to evaluate: (w=0, b=1), (w=0, b=2), (w=0, b=3), (w=0, b=4), (w=1, b=2), (w=1, b=3)

Manually calculating the probability at each we find that the respective probabilities are ~ 0.722, 0.688, 0.643, 0.583, 0.547, 0.542

This means the best probability of picking a black ball is obtained when 1 black ball is moved to the other bag.