Heaven

A person dies, and arrives at the gate to heaven. there are three doors. one of them leads to heaven. another one leads to a 1-day stay at hell, and then back to the gate, and the other leads to a 2-day stay at hell, and then back to the gate. every time the person is back at the gate, the three doors are reshuffled. How long will it take the person to reach heaven?

this is a probability question – i.e. it is solvable and has nothing to do with religion, being sneaky, or how au dente the pasta might be 😉

Solution

1/3 of the time, the door to heaven will be chosen, so 1/3 of the time it will take zero days. 1/3 of the time, the 1-day door is chosen; of those, the right door will be chosen the next day, so 1/9 trips take 1 day. Similarly, 1/9 will take two days (choosing the 2-day door, then the right door).

After that, the cases split again, and again, and again. I can’t seem to make a nice infinite sum this way, so let’s try again.

Suppose the average days spent is X. 1/3 of the cases are done in zero days as before. 1/3 of the cases are 1 day plus X. 1/3 are 2 + X. So:

X = 1/3 * 0 + 1/3 * (1 + X) + 1/3 * (2 + X)
= 0 + 1/3 + X/3 + 2/3 + X/3
= 1 + 2X/3

Therefore,

  X/3 = 1
X = 3

On average, it takes three days to get to heaven. Two if the noodles are limp.

Took me one blind alley, and about five minutes. (heh heh)

2026 Update: Bayesian Reasoning in Tech Interviews

Conditional probability puzzles — where you must apply Bayes theorem correctly — are now more important than ever in ML-adjacent roles. The base rate fallacy (ignoring the prior when updating beliefs) is a genuine failure mode in real ML systems.

The classic base rate trap (asked at Google in 2026):

“A medical test is 99% accurate. A disease affects 1 in 10,000 people. If a patient tests positive, what is the probability they actually have the disease?”

def bayesian_update(prior, sensitivity, specificity):
    """
    Compute P(disease | positive test) using Bayes theorem.
    prior: P(disease)
    sensitivity: P(positive | disease) = true positive rate
    specificity: P(negative | no disease) = 1 - false positive rate
    """
    false_positive_rate = 1 - specificity
    # P(positive) = P(positive|disease)*P(disease) + P(positive|no disease)*P(no disease)
    p_positive = sensitivity * prior + false_positive_rate * (1 - prior)
    # Bayes: P(disease | positive) = P(positive | disease) * P(disease) / P(positive)
    return (sensitivity * prior) / p_positive

result = bayesian_update(prior=0.0001, sensitivity=0.99, specificity=0.99)
print(f"P(disease | positive): {result:.4f}")  # ~0.0098 = less than 1%!

The answer — under 1% despite 99% accuracy — illustrates why high-precision fraud detectors and medical screeners still generate many false positives at low base rates. Understanding this is essential for any ML engineer building classification systems.

Scroll to Top