Interview Question: Egg Problem

#1

Just heard this relatively well-known interview question and thought I’d put it out to you guys. I think I have the answer… what do you think?!

‘’‘Egg Question’’’

You are given 2 eggs. You have access to a 100-storey building.

Eggs can be very hard or very fragile, meaning it may break if dropped from the first floor or will not even break if dropped from 100th floor.

Both eggs are identical. You need to figure out the highest floor of a 100-storey building an egg can be dropped without breaking.

Now the question is how many drops you need to make? …you are allowed to break 2 eggs in the process.

#2

I’m not sure I totally understand the question, but shouldn’t you be able to tell after one drop? You can take one, drop it from really any height, and if it breaks it was the very fragile one. If it doesn’t break, it is the very hard egg which will not break even if dropped from a great height.

#3

The question is asking you how you would work out the highest floor you can drop an egg from on in a 100 story building without it breaking.

#4

So? What is the answer?

#5

I would drop it from floor 100. Seing as you can’t get any higher than that and if it stays intact - well thats the highest floor. However, I’m not great at these questions so I’d love to know the answer.

#6

I was given this in a stats class, and i developed some complex formula for it, but im sure theres probably a much more simple way to do it.

Question is asking you to determine the maximum number of drops you would need to make to work out from what floor eggs can be dropped without breaking. It sees how you break down a question and determines your logical approach to tackling a question.

Basically what you would need to do is move up the building in decreasing steps of 1 each time till you get to the top. This is because as soon as you break the first egg you need to start moving up one at a time from the lower interval.

The maximum number of drops you would need to work out what floor you can drop the eggs from is 14. You would drop the first egg from the 14th floor and if it doesnt break from the 27th, 39, 50, 60, 69, 77, 84, 90, 95, 99, 100 until it breaks at which point you would start at the previous level plus 1 then moving up each singular floor until the second egg breaks or unless it doesn’t at the 100th floor.

So the minimum number of drops in this process would be 2 at 14th and 1st if both break and maximum would be 14
14,1,2,3,4,5,6,7,8,9,10,11,12,13
14,27,15,16,17,18,19,20,21,22,23,24,25,26
14,27,39,28,29,30,31,32,33,34,35,36,37,38
14,27,39,50,40,41,42,43,44,45,46,47,48,49
14,27,39,50,60,51,52,53,54,55,56,57,58,59
14,27,39,50,60,69,61,62,63,64,65,66,67,68
14,27,39,50,60,69,77,70,71,72,73,74,75,76
14,27,39,50,60,69,77,84,78,79,80,81,82,83
14,27,39,50,60,69,77,84,90,85,86,87,88,89
14,27,39,50,60,69,77,84,90,95,91,92,93,94
14,27,39,50,60,69,77,84,90,95,99,96,97,98
When the second egg breaks you know the highest level is that level -1.

lil.x

#7

I guess we need a single drop. The ethier of the eggs would be hard & wont break if it is droped from the highest floor. So we go to the 100th floor & then we drop the first one then there are 2 conditions. 1st it will break & 2nd it wont. If it does break then we know the one we are left with is the hard one. 2nd Condition if it doesnt break then we can say the one which we droped is the hard one.
I guess this would be common sense!

lil.x its good u have tried such a complex algorithm but i believe it wont be useful in the interview as you have got limited time.

VK

#8

As the eggs are both ‘identical’, it has nothing to do with how hard or soft either of them might be.
Surely the formula is:
D-1=x? Where D is the number of drops (assuming you start at the bottom floor), and x is therefore D-1 as the final drop you make will crack the egg and therefore not be the highest floor you can drop an egg from without it cracking (and what we are trying to find here - the highest floor you can drop an egg from).
I can’t see a more logical way of testing?
Start with the bottom floor and work your way up until an egg breaks when it lands, include that drop within the number, as it is still a drop, and then minus that final floor, you have your answer of how many drops it takes to find out the highest floor without cracking the egg.
Hmmm…