KatInterview

Three Probability Puzzles

Arrays & HashingAuto-graded · 16 test cases
MediumAuto-gradedArrays & Hashingprobabilityoptimal-stoppingpoisson-process

Last updated

Tests understanding of optimal stopping, geometric probability, and Poisson processes through three independent probability calculations.

Three Probability Puzzles

Calculate exact answers for three unrelated probability scenarios. State your probabilistic model and show clear reasoning for each part.

Part 1: Die Rolling Game

You play a game with a fair six-sided die. You get up to three rolls total. After seeing each roll's outcome, you must decide whether to keep that value as your score or roll again. If you roll again, you discard the previous result. If you've used all three rolls, you must keep the final value.

Determine the optimal strategy (which outcomes to accept after each roll) and calculate the expected score under optimal play.

Part 2: Random Meeting Window

Two friends plan to meet within a one-hour window. Each arrives at a uniformly random time during that hour, independent of the other. Each person waits for exactly 15 minutes after arriving, then leaves if the other hasn't shown up.

Calculate the probability that the two friends successfully meet.

Part 3: Traffic Observation

On a particular road, the probability of observing at least one vehicle during a one-hour period is 0.96. Vehicle arrivals follow a Poisson process with a constant rate.

Calculate the probability of observing at least one vehicle during a 30-minute period.

Constraints

  • All die rolls produce outcomes 1 through 6 with equal probability (1/6 each)
  • Die rolls are independent of each other
  • Arrival times in Part 2 are continuous and uniformly distributed over [0, 60] minutes
  • The two arrival times are independent
  • Part 3 assumes a stationary Poisson process (constant rate over time)
  • Express all probabilities as exact fractions in simplest form or as string representations like "7/16"

Output Format

Return a dictionary with keys "part1", "part2", and "part3", each containing the specified fields as shown in the function signature documentation.

Examples

Example 1

Input: compute_probability_puzzles()

Output: {'part1': {'sample_space': 'Three independent uniform die rolls, with the final accepted face as the payoff.', 'policy': {'after_roll_1_accept': [5, 6], 'after_roll_2_accept': [4, 5, 6], 'after_roll_3_accept': [1, 2, 3, 4, 5, 6]}, 'continuation_values': {'with_1_roll_remaining': '7/2', 'with_2_rolls_remaining': '17/4'}, 'tie_behavior': 'Stop on a tie; no reachable threshold is an integer here.', 'expected_payoff': '14/3'}, 'part2': {'sample_space': 'The ordered arrival times (x, y) are uniform on the 60 by 60 square.', 'meeting_condition': 'abs(x - y) <= 15', 'complement_geometry': 'Two corner triangles, each with leg length 45 minutes.', 'probability': '7/16'}, 'part3': {'stochastic_assumption': 'Homogeneous Poisson process with independent equal-length half-hour increments.', 'one_hour_no_arrival_probability': '1/25', 'half_hour_no_arrival_probability': '1/5', 'half_hour_at_least_one_probability': '4/5'}}

Hints

Hint 1

For the die game, work backwards from the last roll to determine when to stop at each stage

Hint 2

The meeting problem can be visualized as a square where one axis represents each person's arrival time; the meeting region forms a band around the diagonal

Hint 3

For the Poisson problem, use the relationship between the probability of zero events and the rate parameter, noting that the rate scales linearly with time