![]() |
VOOZH | about |
You are given a building with 100 floors and two eggs. There exists a certain floor, called the critical floor, such that an egg dropped from this floor or any floor below it does not break, while an egg dropped from any floor above it will break.
Conditions
Determine the highest safe floor in a 100-floor building using two eggs, while minimising the maximum number of drops required in the worst case.
Solution:
To minimise the number of drops in the worst case, with 2 eggs and 100 floors, we cannot use binary search because if one egg breaks early, we are left with only one egg and many floors to check.
The idea is to balance the number of attempts in every situation. We start by dropping the first egg from a floor x.
This ensures that the total number of attempts never exceeds x.
To cover all 100 floors, we use the sum of decreasing steps:
x + (x − 1) + (x − 2) + ... + 1 ≥ 100
This is the sum of first x natural numbers:
x(x + 1) / 2 ≥ 100
Now solve:
x(x + 1) ≥ 200
Try values:
13 × 14 = 182 (less than 200, not enough)
14 × 15 = 210 (greater than 200, works)So, x = 14 (approx.)
Now compute the dropping sequence:
Start from 14
Next: 14 + 13 = 27
Next: 27 + 12 = 39
Next: 39 + 11 = 50
Next: 50 + 10 = 60
Next: 60 + 9 = 69
Next: 69 + 8 = 77
Next: 77 + 7 = 84
Next: 84 + 6 = 90
Next: 90 + 5 = 95
Next: 95 + 4 = 99
Next: 99 + 1 = 100So the sequence is:
14, 27, 39, 50, 60, 69, 77, 84, 90, 95, 99, 100
Thus, by following this strategy, we can determine the highest safe floor in at most 14 drops, which is the optimal solution in the worst case.
Read more: Egg Dropping Puzzle (k eggs, n floors).