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.
2 egg 100 floors javascript solution.
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.
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.
And you need to find it in a way suc.
Two results break or not.
2 eggs 100 floors worst case solution.
So the maximum number of tries is 100 for 100 floors.
This is not a john malkovich movie.
One of the floors is the highest floor an egg can be dropped from without breaking.
Two cases arise 1 if egg breaks we have one egg left so we need three more trials.
We now have all the information to compute the optimal two egg solution.
If the egg breaks then we can use the second egg to go back to the first floor and try again.
There is a better way.
2 eggs 100 floors worst case solution.
You have access to a 100 storey building.
A building has 100 floors.
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.
Drop egg from the 50st.
N n 1 2 100.
4 we first try from 4 th floor.
The following is a description of the instance of this famous puzzle involving 2 eggs and a building with 100 floors.
This problem is a specific case of n eggs and k floors.
If the 1st egg does not break then we can go ahead and try on the 4th floor in multiples of 2.
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.
You are given 2 eggs and you are in a building with 100 floors.
This is a quadratic equation with the positive root of 13 651 which we have to round up to 14.
Let s start at the second floor.
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 figure out the highest floor of a 100 storey building an egg can be dropped without breaking.
You are given 2 eggs.
Given 2 eggs and k floors find the minimum number of trials needed in worst case.