Home > Riddles > The 100-story building and the two eggs

The 100-story building and the two eggs

Visual trapsLevel 2/5

It is not a problem of bravery or patience, but of worst-case design. All its elegance lies in finding a plan that shines not when everything goes right, but when everything goes wrong.

You have two identical eggs and access to a 100-story building. There is a critical floor such that:

  • if an egg is dropped from that floor or from a higher one, it breaks;
  • if dropped from a lower floor, it does not break. You need to determine that critical floor by minimizing, in the worst case, the number of launches. What is the optimal strategy?

Hints

Show hints
  1. In the worst case it is not advisable to always advance with equal leaps.
  2. If the first egg breaks, the remaining section with the second must fit exactly in the attempts you have left.
  3. That is why the jumps of the first egg must be adjusted as you go up.

Solution

Show full solution

Answer: The worst case minimum is 14 throws. Explanation: Two risks must be balanced:

  • if the first egg breaks too soon, you need many linear attempts with the second one;
  • if you reserve it too much, you spend too many throws raising. The optimal strategy is to lower the remaining margin one by one:
  • first try on the 14th floor,
  • then on the 27th,
  • then in 39,
  • then in 50,
  • and so on, each time adding a jump one smaller unit. Because? Because this way, if the egg breaks in one test, the number of floors left to check with the second one exactly matches the number of throws still available. You need a number $n$ such that

$$ 1+2+\cdots+n \ge 100. $$

The smallest is $n=14$, because

$$ 14\cdot 15/2 = 105. $$ That's why 14 is the guaranteed minimum. $$

Related riddles

Keep practicing

If you enjoyed this one, try more pure-logic riddles, explore this theme, browse the full archive, or read the riddle-solving guide.

← Previous: The clock and its hands · Next: The rope alrededor of the Tierra →