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