Drop egg from the 50st.
2 egg 100 floors javascript solution.
Suppose that we wish to know which stories in a 100 story building are safe to drop eggs from and which will cause the eggs to break on landing.
The solution for the worst case in this scenario occurs when the threshold floor is floor number 14 because we will drop the first egg on floor 14 and it will break.
There is a better way.
And you need to find it in a way suc.
This problem is a specific case of n eggs and k floors.
4 we first try from 4 th floor.
This is not a john malkovich movie.
Let s talk about the 2 egg problem courtesy of interview cake.
One of the floors is the highest floor an egg can be dropped from without breaking.
You are given 2 eggs and you are in a building with 100 floors.
2 eggs 100 floors worst case solution.
N n 1 2 100.
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.
We now have all the information to compute the optimal two egg solution.
Then we have to test floors 1 13 with the 2nd egg to see where the egg breaks again and the egg will not break on any of those floors.
You need to find the minimum floor where the egg breaks.
If the 1st egg does not break then we can go ahead and try on the 4th floor in multiples of 2.
The solution for the worst case in this scenario occurs when the threshold floor is floor number 14 because we will drop the first egg on floor 14 and it will break.
This is a quadratic equation with the positive root of 13 651 which we have to round up to 14.
If the egg breaks the nth floor is between 49 and 2 if not we know the nth floor is between 51 and 99 we know the egg will not break if dropped from the first floor because it is the minimum distance you can drop the egg and we know that the egg will break at floor 100 the maximum distance you can drop the egg.
The following is a description of the instance of this famous puzzle involving 2 eggs and a building with 100 floors.
You are given 2 eggs.
2 eggs 100 floors worst case solution.
Two cases arise 1 if egg breaks we have one egg left so we need three more trials.
K 10 output.
A building has 100 floors.
So the maximum number of tries is 100 for 100 floors.
Given 2 eggs and k floors find the minimum number of trials needed in worst case.
Eggs can be very hard or very fragile means it may break if dropped from the first floor or may not even break if dropped from 100 th floor both eggs are identical.
You have access to a 100 storey building.