ML Interview Q Series: Card Guessing Strategy: Evaluating Information Gain Using Total Probability
Browse all the Probability Interview Questions here.
Your friend has chosen at random a card from a standard deck of 52 cards but keeps this card concealed. You have to guess what card it is. Before doing so, you can ask your friend either the question whether the chosen card is red or the question whether the card is the ace of spades. Your friend will answer truthfully. What question would you ask?
Short Compact solution
No matter which one of the two questions you ask, your chance of subsequently guessing the card correctly is 1/26 in both cases. Therefore, it makes no difference which question you pose to your friend.
Comprehensive Explanation
To analyze why it does not matter which question you ask, consider the following reasoning. Let A be the event that you guess the card correctly after you have received your friend’s truthful answer.
Define B1 as the event that your friend’s answer is “yes,” and B2 as the event that your friend’s answer is “no.” The total probability of guessing correctly can be computed with:
where
• P(A|B1) is the probability of guessing correctly given that your friend answered “yes,” • P(B1) is the probability that the answer is “yes,” • P(A|B2) is the probability of guessing correctly given that your friend answered “no,” • P(B2) is the probability that the answer is “no.”
Case 1: Asking “Is the card red?”
If the friend says “yes,” then the card is among the 26 red cards in the deck. Your probability of guessing the correct card out of those 26 is 1/26. The probability of your friend saying “yes” is 1/2, because half the deck is red.
If the friend says “no,” then the card is among the 26 black cards. The probability of guessing it correctly among those 26 is again 1/26. The probability of your friend saying “no” is also 1/2.
Plugging these into the total probability expression:
P(A) = (1/26)(1/2) + (1/26)(1/2) = 1/52 + 1/52 = 1/26.
Case 2: Asking “Is the card the ace of spades?”
If the friend says “yes,” that means the card is specifically the ace of spades. Since there is only one such card, you will guess it with probability 1. The probability of this happening is 1/52, since only 1 card out of 52 is the ace of spades.
If the friend says “no,” that means the card is among the remaining 51 cards, and you then guess one of those 51. Your probability of guessing correctly from those 51 is 1/51. The probability that the friend says “no” is 51/52.
Putting these together:
P(A) = 1 * (1/52) + (1/51)(51/52) = 1/52 + (1/51 × 51/52) = 1/52 + 1/52 = 1/26.
Either question leads to the same probability of success, 1/26, so there is no advantage in asking one over the other.
Possible Follow-Up Questions
Why does partitioning the deck this way always lead to 1/26?
The core reason is that each question effectively divides the deck into two groups. When you ask “Is it red?” you get a yes/no split with equal halves, and you guess in the relevant half. When you ask “Is it the ace of spades?” the yes/no split is highly uneven, but your guess adjusts to the size of the partition. In each case, the weighted probability you end up with is 1/26. A more general principle is that asking a single yes/no question cannot fundamentally increase your odds of picking exactly the correct card beyond this 1/26 threshold.
Could a different question yield a better probability?
Any yes/no question partitions the deck of 52 cards into two subsets. Even if these subsets are unbalanced, your probability of an exact guess after one truthful yes/no response balances out in the same way. Since the question is always constrained to have only two possible answers, your expected probability of correctly identifying the single card remains the same.
Is there a way to simulate this to confirm?
Yes. You can simulate this in Python by randomly selecting a card, asking one of the two questions, generating an answer, and then attempting to guess from the implied subset. Tracking the number of successful guesses over many simulations will approximate 1/26. A simple illustration:
import random
def simulate_question(num_trials=10_000_000):
import random
cards = [(v, s) for v in range(13) for s in range(4)] # 52 unique cards
success_red_question = 0
success_spade_question = 0
for _ in range(num_trials):
chosen_card = random.choice(cards)
# Scenario 1: Ask "Is it red?"
# If yes -> chosen_card is in red suits. Probability of correct guess is 1/26 if red, else 0.
is_red = (chosen_card[1] in [0, 1]) # Assume suits 0 & 1 are red, 2 & 3 are black
if is_red:
success_red_question += (1 if random.randrange(26) == (chosen_card[0] + chosen_card[1]*13) % 26 else 0)
else:
success_red_question += (1 if random.randrange(26) == (chosen_card[0] + chosen_card[1]*13) % 26 else 0)
# Scenario 2: Ask "Is it the ace of spades?"
# If yes -> only 1 possibility, guess is always correct.
# If no -> guess among the remaining 51 cards.
is_ace_spades = (chosen_card == (0, 3)) # Let's say value=0 -> Ace, suit=3 -> spades
if is_ace_spades:
success_spade_question += 1
else:
success_spade_question += (1 if random.randrange(51) == 0 else 0)
print("Probability with red question:", success_red_question / num_trials)
print("Probability with ace of spades question:", success_spade_question / num_trials)
simulate_question()
Running this code many times will show that both probabilities converge to about 1/26. This confirms that neither question gives you an advantage.
What if you asked multiple yes/no questions?
The scenario in this problem is restricted to a single yes/no question before guessing. If you were allowed multiple questions, you could narrow down possibilities further, thereby increasing the probability of guessing the exact card. With enough questions, you could theoretically identify the card with complete certainty. However, the question here confines you to just one yes/no response, which yields a 1/26 probability for any such partition-based question.
Is there a practical or intuitive interpretation?
Yes. You have exactly one opportunity to gain some piece of information about a single unknown card. Whether the partition that information produces is balanced (like red vs. black) or unbalanced (like ace of spades vs. everything else), your final chance to name the correct card after that partition ends up the same. The formula for total probability ensures that any single yes/no partition, followed by a guess within that subset, gives the same final probability of success.
Below are additional follow-up questions
What if the deck is not perfectly random or contains missing cards?
If the deck your friend is choosing from is not a full standard 52-card deck, or if certain cards have higher or lower probability of being selected, the previous conclusions change. In a real-world setting, decks can be missing cards or might be biased (e.g., the friend consistently forgets to remove jokers, or certain cards might be bent and thus more likely to be selected). If it is not guaranteed to be a uniform random draw, the probability calculation you derived (1/26) will not hold directly.
If some cards are more likely than others, then asking a question like “Is it the ace of spades?” might yield a different probability of a “yes” answer. If there is a 3% chance that the chosen card is the ace of spades (instead of 1/52 ≈ 1.92%), that changes the resulting probabilities.
You would need to compute P(ace_of_spades) separately from P(not_ace_of_spades) based on the actual distribution. This might give a yes/no partition that no longer balances out to 1/26 overall.
Similarly, if a few cards are missing, the total deck size could be 50 or 51. You would then re-calculate the probabilities accordingly.
The pitfall is to assume the standard 52-card uniform distribution when, in practice, the selection process may not be perfectly random or the deck might be incomplete.
How could human error in answering affect your strategy?
In a purely theoretical setting, we assume that your friend’s yes/no answer is always truthful. However, real humans can make mistakes:
If your friend might answer incorrectly with some small probability p, you cannot fully rely on the partition implied by their answer. You no longer have a clean split of the deck, because each of the two outcomes is now uncertain.
Formally, if you let p be the probability that your friend makes an error, you must factor this into the conditional probabilities. For example, if you asked “Is the card red?” then a “yes” might still mean the card could be black with probability p.
This changes the final guess: you must decide how much weight to put on each subset of the deck. You might end up guessing whichever subset has the higher posterior probability.
The real-world subtlety is that even slight miscommunication or misunderstanding of the question can alter the partitions, so you may not get the 1/26 result in practice.
Could you gain information by asking a cleverly ambiguous question?
The puzzle states you can only ask a yes/no question, but one might wonder whether a more cryptic or multi-layered question could yield more than a single bit of information. The constraint is that any question must have exactly two unambiguous possible answers—“yes” or “no.” If you tried to encode multiple possible outcomes in a single question, the friend would still only respond with a single yes or no, effectively splitting the deck into two subsets.
If your question were ambiguous (e.g., “Is the card in a black suit or is it a face card that belongs to hearts or diamonds?”), you still only get a single answer. No matter how you phrase it, you only partition the deck into two groups.
You might accidentally ask a question that’s interpreted differently by your friend, which again leads to uncertain or inconsistent partitioning, causing the probability to deviate from the ideal calculation.
Thus, the pitfall is assuming you can encode more information into a yes/no response than actually possible. In practical terms, your question must be crystal clear and unambiguously binary.
Is the 1/26 result dependent on the question always having a strict yes/no format?
Yes. If you were allowed to ask a question with more possible responses (e.g., “Please tell me the suit” which has four possible answers), you obviously get more information. But as soon as you fix the answer possibilities to exactly two, the best you can do is a partition of the sample space into two subsets. That inherently leads back to the 1/26 overall success probability:
In theory, each card can be considered an equally likely event from a set of 52. A single binary question can at most reduce the uncertainty so that you are left to guess from some subset.
If you consider the total probability formula for guessing correctly, you end up with 1/26 no matter how you label those subsets “yes” or “no.”
The edge case is if your question somehow did not produce a valid yes/no at all, but that would break the premise of the puzzle.
Does this logic change if you get a second guess?
Sometimes interviewers might challenge you with a slight twist: “What if you get two guesses after the yes/no question?” If two guesses are allowed, the math changes substantially.
With two guesses, you effectively get the opportunity to cover two cards in the relevant subset. For instance, if you asked “Is it red?” and got “yes,” you can guess two specific red cards out of 26.
That gives you a probability of 2/26 = 1/13 of success if the answer is “yes,” and 2/26 = 1/13 if the answer is “no,” leading to an overall probability of 1/13.
If the question is “Is it the ace of spades?” and the answer is “yes,” you guess it correctly immediately. If the answer is “no,” you then can guess two among 51 possible cards, giving 2/51. Weighting by 1/52 vs 51/52, you can compute that new total. The point is that with more guesses, the probability grows accordingly, but still remains the same across any yes/no question structure.
The subtlety is that once you alter the number of guesses, your strategy to guess from the resulting subset changes, but the universal partition principle still dictates the final probability in a symmetrical manner, just scaled by the number of guesses.
What if the suits or ranks matter differently in a game context?
In some card games, certain suits or ranks might carry a bigger reward or penalty. This puzzle focuses purely on identifying the single chosen card, but if you had a different goal (for example, you only care if the chosen card is a trump suit in a trick-taking game), you might ask a question that partitions the deck into relevant suits or ranks.
In such a scenario, your question might help you maximize your expected utility, not just your probability of a perfect guess.
For instance, you could ask something like “Is it worth more than 10 points in the game’s scoring system?” to optimize your payoff. That might not maximize the probability of an exact identification of the card, but it could maximize your expected score in a real game.
The pitfall is thinking that the puzzle’s solution about 1/26 always applies, while ignoring that real card games might have different objectives. The puzzle specifically concerns guessing the identity of the card, not a broader notion of expected gain or partial correctness.
What if you could defer your question until after seeing partial information?
In certain in-person card trick scenarios, you might see the orientation of the card or glean partial clues (like a corner mark or a shadow) before asking your question. If you already gather partial information, you effectively reduce the deck size or shift probabilities even before your yes/no question.
For example, if you somehow see the color of the card’s edge (maybe it is slightly visible), you already know if it is red or black. Then asking “Is the card red?” would be pointless, but another question might yield a better partition.
In a practical sense, once you have any prior knowledge, the best yes/no question to ask is the one that best splits the remaining plausible subset.
The subtlety is that the puzzle’s 1/26 result relies on the assumption that you have no information about the card prior to asking your single question. If you have partial information, the situation changes, and you might do better than 1/26.
Is there a scenario where you might not want to guess even after the yes/no answer?
Although the puzzle states you must guess the card, consider a hypothetical variation: you receive a yes/no clue, then have the option to guess or refuse to guess. In typical puzzles, refusing yields zero chance of winning, so you guess anyway. But in a game with negative scoring for wrong guesses, you might choose not to guess if the expected payoff of guessing is worse than zero.
If guessing incorrectly yields a large negative penalty, you might only guess when you have a sufficiently high confidence. With a single yes/no question dividing 52 cards, your confidence is 1/26, which might be too low if the penalty is steep.
You would compute your expected value. For instance, if success yields +1 and failure yields –2, your expected value is (1/26)(+1) + (25/26)(-2) = 1/26 – 50/26 = –49/26, which is negative. So you might choose not to guess at all.
The pitfall is assuming that 1/26 is always an acceptable probability. In real betting or scoring scenarios, you must weigh the risk and reward.