Search⌘ K
AI Features

Practice Set: Probability Puzzles

Explore common probability puzzles used in data science interviews by defining events, calculating exact probabilities, and validating results with simulations. Learn to explain assumptions and reasoning clearly while solving for scenarios like coin toss sequences, dice outcomes, card draws without replacement, birthday collisions, expected value in games, and the Monty Hall problem.

Approach probability problems by defining the event of interest, identifying the possible outcomes, and deriving the probability before applying a formula. For each problem, explain the setup and assumptions before calculating the probability. This allows the interviewer to evaluate the reasoning rather than just the final answer. A Monte Carlo simulation can provide an independent numerical check of the analytical result, but it does not replace the mathematical reasoning required to derive the answer.

The six problems cover the probability of an exact coin-toss sequence, conditional probability with dice, card draws without replacement, the birthday problem, an expected-value game, and a conditional probability problem involving new information. Each problem includes two hints, a step-by-step analytical derivation, a reasonableness check, an optional numerical verification using NumPy, and a follow-up question that modifies the original conditions. Attempt each problem independently before reviewing Hint 1, Hint 2, and the full derivation, in that order.

Problem 1: HHT in three flips

Scenario: In the first problem, a fair coin is flipped three times. Calculate the probability of obtaining the sequence HHT (heads, heads, tails) in that exact order. Each flip is independent, with a probability of 1/2 for heads and 1/2 for tails.

Question: What is the probability of seeing HHT in that exact order in three flips of a fair coin?

List the position of each required outcome. The first flip must be H, the second must be H, and the third must be T.

Solution

The event is the one ordered sequence HHT, not any sequence with two heads and one tail.

The same result follows from sample-space counting. Three flips produce 23=82^3=8 equally likely sequences, and only one sequence is HHT.

The answer is below 1/21/2, as it should be. Any particular three-flip sequence has the same probability as TTT or THH; order changes the event but not its probability.

Optional simulation check:

Python 3.14.0
import numpy as np
rng = np.random.default_rng(0)
flips = rng.integers(0, 2, size=(100_000, 3)) # 1 = H, 0 = T
print(np.mean((flips == [1, 1, 0]).all(axis=1)))

Code explanation:

  • rng: A random generator with a fixed seed, so every run produces the same numbers.

  • flips: 100,000 rows of three flips each, with 1 for heads and 0 for tails.

  • (flips == [1, 1, 0]).all(axis=1): Marks each row that matches HHT exactly, and np.mean turns those matches into a proportion.

This prints a value near 0.125.

Follow-up question: We keep flipping until HHT first appears. How many flips does that take on average?

Answer: The probability 1/81/8 does not answer this directly, because the attempts overlap: a run of flips can be partway to HHT when it fails. Track how much of the pattern we have built. Let E0E_0 be the expected number of further flips from scratch, E1E_1 after a single H, and E2E_2 ...