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 out of a window from that floor. If an egg is dropped and does not break, it is undamaged and can be dropped again. However, once an egg is broken, that’s it for that egg.
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, then it will survive any fall shorter than that.
The question is: What strategy should you adopt to minimize the number egg drops it takes to find the solution? (And what is the worst case for the number of drops it will take?)
start at 9, if it breaks go through floors 1-8 successively, if doesn’t break go to floor 18 and go through floors 10-17 and repeat the process by increasing the floor number by 9 if the egg does not break.
At most, it will take 18 attempts
This sounds good, how many attempts would this strategy take if the egg breaks on floor 98 though?
Start on 10 if breaks (b) 123456789 if nb 20 b 11 12 13 14 15 16 17 18 19 if nb 30…..
Hi, I figured that it would be best to trow the first egg down at certain intervals, the bigger the intervals, the less you have to drop the egg. However, when it breaks, the second egg has to be dropped from every floor between the last successful landing floor and the broken egg floor, here, the bigger the intervals, the more you’ll have to drop the second egg.
Imagine that we drop the first egg at intervals of 2. we drop it 50 times (worst-case scenario) and on the 50th it breaks, we then need to throw the second egg only once, so 51 times in total. This solution to the nth term would be 100/n + n – 1. where n is the size of the interval.
Interval 1 = 100
Interval 2 = 51
Interval 3 = 35
Interval 4 = 28
Interval 5 = 14
Interval 6 = 21
Interval 7 = 20
Interval 8 = 19
Interval 9 = 19
Interval 10 = 19
Interval 11 = 19
Interval 12 = 19
Interval 13 = 19
Interval 14 = 20
Interval 15 = 21
Interval 16 = 22
(it gets a little weird after but the number continues to grow, so the optimal strategy is throwing eggs down at intervals 8, 9, 10, 11, 12, 13 and then between the last 2 tested floors at intervals of 1. the worst case scenario would be 19 throws.
Hi it’s Eusila . I like the way of thinking..
Hi, am Eusila Kitur studying in M-pesa Foundation academy . About the two eggs problem ,we would first go to floor 50 ,the half of the building and drop an egg. By so doing our problem will be cut half way since the outcome will be ,the egg may break or it may not .If it breaks we will know that the solution is lying under the floor 50 (1-49) but when it will not break then the solution will be within floor (51-100) . We divide it half by half till we get the solution at the end in short finding the log.
First we go to floor 50 ,the half of the building and drop an egg.By doing so we divide the problem into a half since the outcome may break or not.If it breaks the solution is found from floor 49 downwards.If it does not then the solution lies in the top half of the building.We will divide it halve times until we get the solution.The minimum number of eggs is as many as much we throw wether in floor 100 or ground floor.
So challenging.I am peter from m-pesa foundation academy and the strategy I came with was:Because I have identical eggs I will take the first one and start to drop the egg from the first floor of the building and if the egg breaks I will stop there bearing in mind that even the above floors will also break.
If the egg doesn’t break in the first floor I will go to the above floor and apply the same strategy until i reach the floor in which the egg will break.
When I reach to a floor the egg can break I will go to the floor below which the egg broke and mark that floor as the highest floor in which the egg can’t break when dropped in the window.
Otherwise thank you