Probability That One Customer's Two Coffees Beat Another's Two
MercorSoftware Engineer · Technical ScreenLast updated
A probability puzzle in which two customers each buy two cups of coffee of random quality, and you find the chance that one customer's cups are better than the other's. It tests clarifying what better means, using symmetry over rankings, checking the result a second way, and reasoning about ties and correlated cups.
A coffee shop's drinks vary in quality from cup to cup. Customer A and customer B each buy two cups. What is the probability that A's two cups taste better than B's two cups?
Constraints and Clarifications
- Unless the interviewer says otherwise, assume each cup's quality is a continuous random variable and the four cups' qualities are independent and identically distributed.
- Take "A's two cups are better than B's two cups" to mean that each of A's cups is better than each of B's cups. Be ready to answer the other readings listed below as well.
Clarifying Questions
- Does "better" mean that each of A's cups beats each of B's cups; that A's better cup beats B's better cup and A's worse cup beats B's worse cup; or simply that A's two cups have the higher total quality?
- Is quality continuous, or rated on a coarse scale where two cups can be equally good? If ties are possible, how do they count?
- Are the four cups independent, or can cups bought together, for example poured from the same pot, be correlated?
Hints
Hint 1
Only the order matters: Ask whether the answer can depend on how quality is distributed. If it cannot, think about what is left to randomize once you only look at how the four cups rank against each other.
Hint 2
Check it a second way: Once you have a number, confirm it with a different argument, for example by following where the single best cup of the four ends up.
Follow-up questions
- Generalize: A buys `m` cups and B buys `n` cups. What is the probability that every one of A's cups beats every one of B's?
- Suppose each cup is independently either good, with probability `p`, or bad. What is the probability that both of A's cups are strictly better than both of B's?
- Does the answer still hold if each customer's two cups are poured from the same pot, so they are correlated? Which property of the four qualities does the main answer actually need?
Solution walkthrough is for members
Get the full walkthrough with reference code and complexity analysis, plus Kitty Coach at 300 messages a day. Hints, the code runner and community answers stay free.