Find the Color Probability After Discarding Cards
OptiverSoftware Engineer · Technical ScreenLast updated
This problem tests your understanding of conditional probability, combinatorics, and how dependent events (sampling without replacement) impact statistical expectations.
Problem Statement
You are given a standard deck of 52 playing cards, containing 26 red cards and 26 black cards. The deck is shuffled such that every permutation is equally likely. Suppose you draw cards one by one from the top of the deck without replacement.
Tasks
- Let
R_nbe the number of red cards andB_nbe the number of black cards remaining in the deck afterncards have been drawn. Calculate the probability that the next card drawn (then+1-th card) is red, given that you have already observedrred cards andbblack cards drawn so far, wherer + b = n. - Suppose you discard the first 10 cards without looking at them. Without any knowledge of the colors of the discarded cards, what is the probability that the 11th card is red? Explain your reasoning.
- Consider a scenario where the deck is 'rigged': instead of 26/26, the deck contains
Rred andBblack cards. Provide a general formula for the probability that thek-th card is red, given no information about the previousk-1cards.
Constraints
0 <= n < 520 <= r <= 26,0 <= b <= 26
Example
If you have drawn 2 red cards and 0 black cards (n=2), the probability that the 3rd card is red is (26-2) / (52-2) = 24 / 50 = 0.48.
Hints
Hint 1
Recall that for sampling without replacement, the probability of an event depends strictly on the count of items remaining in the population.
Hint 2
Consider whether the lack of information about the discarded cards implies that the probability 'resets' or remains unchanged due to symmetry.
Hint 3
Use the law of total probability or symmetry arguments to justify why the marginal probability of the k-th card being red remains the same as the first card.
Follow-up questions
- How does the probability change if you draw cards until you observe 5 red cards and then stop? Is the probability of the next card being red still 0.5?
- If you know the first card is red, but you do not know the last card, what is the probability that the last card is black?
- How would you simulate this process for a deck of size N with R red and B black cards to verify your mathematical derivation?
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.