TITLE: Egg drop problem
QUESTION [9 upvotes]: Suppose that you have an $N$-story building and plenty of eggs. An egg breaks if it is dropped from floor $T$ or higher and does not break otherwise. Your goal is to devise a strategy to determine the value of $T$ given the following limitations on the number of eggs and tosses:



Version 0: $1$ egg, $\leq T$ tosses 
Version 1: $\text{~}1$ $\text{lg}$$(N)$ eggs and $\text{~}1$
  $\text{lg}(N)$ tosses. ($lg$ is log base 2)
Version 2: $\text{~}1$ $\text{lg}$$(T)$ eggs and $\text{~}2$
  $\text{lg}$$(T)$ tosses
Version 3: $2$ eggs and $\text{~}$ $2\sqrt{N}$ tosses
Version 4: $2$ eggs and $\text{~}$ $\sqrt{2N}$ tosses
Version 5: $2$ eggs and $\leq$ $2\sqrt{2T}$ tosses


I think I have the answer for most of these but don't know how to do a few. Could you please check over my work and provide hints on how to approach the ones I don't know how to do?

For version 0, a simple iterative search starting from the 1st floor and working up to the $N$th floor in increments of 1 will work.
For version 1, a binary search across the floors $1$ to $N$ will work.
For version 2, I think you can iteratively double floors, visiting $1$, then $2$, then $4$, then $8$, etc. until the egg breaks at floor $2^k$. Then you can binary search across $2^{k-1}$ and $2^k$
For version 3, you can go iteratively go across floors with incrementing by $\sqrt{N}$: first visiting 0, then $\sqrt{N}$, then $2\sqrt{N}$, etc. Once the egg breaks at stage $k\sqrt{N}$, iterate across the range $(k-1)\sqrt{N}$ and $k\sqrt{N}$ one floor at a time.
For versions 4 and 5 I don't know how to start. Can someone please provide a hint?

REPLY [3 votes]: (Version 5: 2 eggs and ≤ 2*sqrt(2)*sqrt(T) tosses)
Drop eggs from floors, 1, 3, 6, 10, 15 and so on.. (3 = 1 + 2, 6 = 1+ 2 + 3, 10 = 1 + 2 + 3 + 4 etc.
Let us say the first egg breaks at floor 21 (that's 1 + 2 + 3 + 4 + 5 + 6). This tells us that T is between 15 and 21. Till now, we have had 6 tosses. 
Now, 1 + 2 + 3 +.....t = t(t+1)/2 which can be approximated to t^2/2 for ease of calculation of t is large. So, the floors at which we have been tossing eggs actually are approx. t^2/2 where t is the number of tosses so far. 
So, let us come back to the example above for clarity. Here t = 6 and t(t+1)/2 (without any approx.) = 21. So, till now we have had t tries. Now, the next step is to keep tossing eggs sequentially from 16 to 21 till the 2nd egg breaks and we find T out.
The worst case scenario for T is 21 as in that case we'll have to keep breaking eggs till we reach 21. Or, we could generalize and say that the worst case scenario for T is t(t+1)/2 (approx. t^2/2) where t tries have been completed. So t = approx. sqrt(2)*sqrt(T).
Total number of tosses required in reaching floor 21 (assuming that's T in the worst case) will be tosses to reach floor 21 (6) + tosses from 16 to 21 (6 again).
Basically, the total number of tosses required in reaching floor T will be t - to reach the upper bound of T (21 in this case) PLUS sequential tries from the floor before t(t+1)/2th floor.
Now t th toss' floor is t(t+1)/2
t-1 th toss' floor is t(t-1)/2 (that's what 1 + 2 + 3 +.... (t-1) is).
The difference between the two turns out to be t (that means t(t+1)/2 - t(t-1)/2 is t). 
So, the maximum number of sequential tries from t(t-1)/2 th floor to t(t+1)/2 th floor is t. 
Hence, the final maximum number of tosses in reaching floor T = tosses in reaching floor t(t+1)/2 + sequential tries from t(t-1)/2 th floor to t(t+1)/2 th floor.
So, maximum tosses required = t + t = 2t.
But t = sqrt(2)*sqrt(T).
So, 2t = 2*sqrt(2)*sqrt(T) = maximum tosses required to reach floor T.