You are given two eggs, and access to a 100-storey building. Both eggs are identical. The aim is to find out the highest floor from which an egg will not break when dropped from a floor. If an egg is dropped and does not break, it is undamaged and can be dropped again. However, once an egg is broken, it cannot be used anymore.
If an egg breaks when dropped from floor N, then it would also have broken from any floor above that. If an egg survives a fall from floor N, then it will also survive any fall below floor N.
What is the minimum number of egg drops required to find the solution?
14 is the least number of tries to find out the solution.
The easiest way to do this would be to start from the first floor and drop the egg. If it doesn’t break, move on to the next floor. If it does break, then we know the maximum floor the egg will survive. If we continue this process, we will easily find out the maximum floors the egg will survive with just one egg. So the maximum number of tries is 100 for 100 floors.
There is a better way. Let’s start at the second floor. If the egg breaks, then we can use the second egg to go back to the first floor and try again. If the 1st egg does not break, then we can go ahead and try on the 4th floor (in multiples of 2). If it ever breaks, say at floor N, then we know it survived floor N-2. That leaves us with just floor N-1 to try with the second egg. With this method, the maximum tries is 51. It occurs when the egg survives 98 floors. It will take 50 tries to reach floor 100 and one more egg to try on the 99th floor so the total is 51 tries.
Now, for the ultimate method. Instead of taking equal intervals, we can decrease the number of floors by one less than the previous one. For example, let’s first try at floor 14. If it breaks, then we need 13 more tries to find the solution. If it doesn’t break, then we should try floor 27 (14 + 13). If it breaks, we need 12 more tries to find the solution. So the initial 2 tries plus the additional 12 tries would still be 14 tries in total. If it doesn’t break, we can try 39 (27 + 12) and so on. Using 14 as the initial floor, we can reach up to floor 105 (14 + 13 + 12 + … + 1) before we need more than 14 tries. Since we only need to cover 100 floors, 14 tries is sufficient to find the solution.
|Egg Drop Count||Floor|
Therefore, 14 is the least number of tries to find out the solution.