Three Probability Puzzles
Arrays & HashingAuto-graded · 16 test casesLast 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
Worked solution
Medium Try it yourself first — then compare your approach, complexity and edge cases.
Approach
This problem requires three separate probabilistic analyses:
Part 1: Optimal Stopping with Backward Induction
Start from the final decision and work backwards. With one roll left, the expected value is (1+2+3+4+5+6)/6 = 7/2. With two rolls remaining, we accept a value if it exceeds 7/2, meaning we keep 4, 5, or 6 (probability 1/2) for an average of 5, or continue (probability 1/2) for 7/2. This gives an expected value of (1/2)×5 + (1/2)×(7/2) = 17/4.
With three rolls, we accept values exceeding 17/4, which means keeping 5 or 6 (probability 1/3, average 5.5) or continuing (probability 2/3) for 17/4. The total expectation is (1/3)×(11/2) + (2/3)×(17/4) = 14/3.
Part 2: Geometric Probability
Model the arrival times as coordinates (x, y) in a 60×60 square. The friends meet when |x - y| ≤ 15, forming a band around the diagonal y = x. The complement consists of two triangular regions: one where y > x + 15 (upper left) and one where x > y + 15 (lower right). Each triangle has legs of length 45 minutes, so area 45²/2.
The probability they don't meet is 2×(45²/2)/(60²) = 2025/3600 = 9/16.
Therefore, the probability they meet is 1 - 9/16 = 7/16.
Part 3: Poisson Process Scaling
For a Poisson process with rate λ, the probability of zero arrivals in time t is e^(-λt). Given P(at least one in 1 hour) = 0.96, we have P(zero in 1 hour) = 0.04 = 1/25.
So e^(-λ) = 1/25, which means e^(-λ/2) = √(1/25) = 1/5.
The probability of at least one vehicle in 30 minutes is 1 - 1/5 = 4/5.
Correctness: Each solution follows from standard probability theory: dynamic programming for optimal stopping, area ratios for continuous uniform distributions, and memoryless scaling for Poisson processes.
Time Complexity: O(1) - all calculations are closed-form expressions.
Space Complexity: O(1) - only stores constant-size dictionary structures.
from typing import Dict
def compute_probability_puzzles() -> Dict[str, object]:
return {
"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"
}
}