You have two coconuts and you want to find out how high they can be dropped from a 100 story building before they break. Now, the elevator in this building costs a quarter to operate-meaning you want to minimize the number of trips you must take.
So how many trips would it take at most to figure out how far the coconuts can fall?
Bear in mind the coconuts are identical; they’ll break at the same point. Also, if they don’t break, they’re considered as good as new.
14 is the least number of trips to find out the solution.
The easiest way to do this would be to start from the first floor and drop the coconut. If it doesn’t break, move on to the next floor. If it does break, then we know the maximum floor the coconut will survive. If we continue this process, we will easily find out the maximum floors the coconut will survive with just one coconut. 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 coconut breaks, then we can use the second coconut to go back to the first floor and try again. If the 1st coconut 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 coconut. With this method, the maximum tries is 51. It occurs when the coconut survives 98 floors. It will take 50 tries to reach floor 100 and one more coconut 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.
Coconut Drop Count | Floor |
---|---|
1 | 14 |
2 | 27 |
3 | 39 |
4 | 50 |
5 | 60 |
6 | 69 |
7 | 77 |
8 | 84 |
9 | 90 |
10 | 95 |
11 | 99 |
12 | 100 |
Therefore, 14 is the least number of tries to find out the solution.