5 Unbreakable Light Bulbs and a 80 Floor Building

IF You have 5 unbreakable light bulbs and a 80 floor building. Using fewest possible drops, determine how much of an impact this type of light bulb can withstand?

Can it withstand a drop from 20th floor, but breaks from the 22th?

2026 Update: Egg Drop With Many Eggs — Binary Search Special Case

With 5 “unbreakable” bulbs (effectively unlimited tries), finding the critical floor in an 80-floor building reduces to binary search: O(log₂ 80) ≈ 7 trials. The interesting comparison is with 2 eggs.

import math

def min_trials(k_eggs: int, n_floors: int) -> int:
    """
    Minimum trials using the inverse: given t trials and k eggs,
    max floors checkable = sum(C(t, i)) for i=1..k.
    Find minimum t.
    """
    t = 0
    while True:
        t += 1
        floors = sum(math.comb(t, i) for i in range(1, k_eggs + 1))
        if floors >= n_floors:
            return t

print("Minimum trials needed:")
for eggs in [1, 2, 3, 5]:
    trials = min_trials(eggs, 80)
    print(f"  {eggs} eggs, 80 floors: {trials} trials")

# Results:
# 1 egg:  80 trials (linear scan)
# 2 eggs: 13 trials (triangular intervals)
# 3 eggs:  7 trials
# 5 eggs:  6 trials (barely better than binary search = log2(80) ~= 7)

# Optimal 2-egg drop schedule (classic interview)
def two_egg_schedule(n_floors: int = 80) -> tuple:
    """
    Optimal intervals for 2 eggs: start high, decrease each time.
    Choose t: t*(t+1)/2 >= n_floors  ->  t = ceil((-1+sqrt(1+8n))/2)
    Drop at floors: t, t+(t-1), t+(t-1)+(t-2), ...
    """
    t = math.ceil((-1 + math.sqrt(1 + 8 * n_floors)) / 2)
    schedule = []
    current = 0
    for step in range(t, 0, -1):
        current += step
        if current <= n_floors:
            schedule.append(current)
    return t, schedule

t, schedule = two_egg_schedule(80)
print(f"n2-egg optimal: {t} trials max")
print(f"Drop at floors: {schedule}")

# Why decreasing intervals work:
# If egg 1 breaks at floor f_k, we have used 1 trial and have 1 egg left.
# We must linearly scan from f_{k-1}+1 to f_k-1 (that's step-k intervals = t-k+1 floors).
# Total always = t regardless of which floor breaks first.

# For 5 unbreakable eggs: binary search
def binary_search_floors(n_floors: int = 80):
    lo, hi = 1, n_floors
    trials = 0
    while lo < hi:
        mid = (lo + hi) // 2
        trials += 1
        # Test floor mid: if egg would break, search below; else above
        # (In practice we don't know, so we must complete all log2(n) trials)
        lo = mid + 1  # Best case: always need to go up
    return trials

print(f"nBinary search trials: {math.ceil(math.log2(80))}")  # 7

Key insight: With unbreakable bulbs (= unlimited eggs), binary search is optimal: ⌈log₂(80)⌉ = 7 trials. With 2 eggs, decreasing intervals (13 trials for 80 floors) is optimal. The gap between 2-egg and many-egg solutions shrinks as floor count grows. This maps to: A/B testing with finite budget, finding breakpoints in production rollouts, and binary search with retry costs.

Scroll to Top