https://www.interviewcake.com/question/python/two-egg-problem
A building has 100 floors. One of the floors is the highest floor an egg can be dropped from without breaking.
If an egg is dropped from above that floor, it will break. If it is dropped from that floor or below, it will be completely undamaged and you can drop the egg again.
Given two eggs, find the highest floor an egg can be dropped from without breaking, with as few drops as possible.
My first inclination would be to use binary search. However, this is hampered by the fact that we can only sacrifice one egg. So the worst-case here would be if the solution were 49: we would start with a drop from 50 (which would break), at which point we would be forced to start from the first floor and increment one floor at a time until we reached floor 49, so 50 drops total.
My next thought is that we can use a bit of mathematical induction to skip some floors. For example, we could start on floor 2, and if that breaks, we know the answer is floor 1 without having to drop a second egg.
If we chain these together, we can hop two floors at a time. Here, the worst-case would be floor 100, which would require 50 drops to deduce.
I think we can combine those approaches and the worst-case (floor 49) is now 25 drops (1 drop of the first egg at @50, then 24 drops with the second egg to deduce that 49 is the answer).
We could increase the number of floors which we skip with each hop to 4, and then bisect that with the remaining egg. A solution of floor 99 is now the worst case, which would require 25 drops with the first egg and two more with the second egg (27 total), so that's no better.
What if we used an increasing hop size with the first egg? Here there is going to be a trade-off between how aggressively we grow the hop-size for the first egg vs. how many hops the second egg will have to make.
Hmm, I think we will have to write a few programs to find that tradeoff.
OK, so the best result I saw there was 31 drops, which isn't as good as the 25 drop solution described above. Graph of results
Here's the first few lines of the results (as CSV), sorted with best solutions on top:
1.20310722171,31
1.20431032893,31
1.20551463926,31
1.2067201539,31
1.22617316074,31
1.2273993339,31
1.22862673324,31
1.13534496912,32
1.13648031409,32
So, solutions with a hop-size multiplier near 1.2 yeilded the best results (31 drops worst-case)