eggdrop.jpgThe puzzle “You have two hard eggs. But the question is ‘how hard are they?’ You have a 100 story building and only the two eggs, how would you find out which is the highest floor of the building you can drop the eggs from, before they break? It could be the 1st floor but it could also be the 99th floor—you must try dropping the eggs from different floors and see what happens. Your goal is to find the answer with the least number of egg drops.”

50th floor, worst case: egg 1: floor 50, 100 (break), then Egg 2: 51-99 : 2 + 49
25th floor, worst case: egg 1: floor 25, 50, 75, 100 (break), then Egg 2: 76-99: 4 + 24
10th floor: Egg 1: floor 10, 20, 30, 40, 50, 60, 70, 80, 90, 100 (break), Egg 2: floor 91, 92, 93, 94, 95, 96, 97, 98, 99: 10 + 9 drops

a function which models this is:

f(x) = 100/x + (x-1), where x is a positive integer less than or equal to 100

to find the local minima of function f(x), take the derivative of f(x) and set it equal to zero

f’(x) = -100/x^2 + 1 = 0

x = 10

So f(x) has a minimum at 10, which is the optimal solution

reference