Sunday, May 2, 2010

How Strong is an Egg?

Question: You have two identical eggs. Standing in front of a 100 floor building, you wonder what is the maximum number of floors from which the egg can be dropped without breaking it. What is the minimum number of tries needed to find out the solution?

Answer: The easiest way to do this would be to start from the first floor and drop the egg. If it doesn’t break, move on to the next floor. If it does break, then we know the maximum floor the egg will survive is 0. If we continue this process, we will easily find out the maximum floors the egg will survive with just one egg. So the maximum number of tries is 100 that is when the egg survives even at the 100th floor.

Can we do better? Of course we can. 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. If it does not break, then we can go ahead and try on the 4th floor (in multiples of 2). If it ever breaks, say at floor x, then we know it survived floor x-2. That leaves us with just floor x-1 to try with the second egg. So what is the maximum number of tries possible? It occurs when the egg survives 98 or 99 floors. It will take 50 tries to reach floor 100 and one more egg to try on the 99th floor so the total is 51 tries. Wow, that is almost half of what we had last time.

Can we do even better? Yes we can (Bob, the builder). What if we try at intervals of 3? Applying the same logic as the previous case, we need a max of 35 tries to find out the information (33 tries to reach 99th floor and 2 more on 97th and 98th floor).

Interval – Maximum tries
1 – 100
2 – 51
3 – 35
4 – 29
5 – 25
6 – 21
7 – 20
8 – 19
9 – 19
10 – 19
11 – 19
12 – 19
13 – 19
14 – 20
15 – 20
16 – 21

So picking any one of the intervals with 19 maximum tries would be fine.

9 comments:

  1. Sorry, that's not the best answer! The best answer is 15.

    Let me illustrate: Say that we only have 10 floors, not 100.
    On the first try, let me pick the 4th floor. If it breaks, I'll spend at most 3 more tries to figure out whether it already breaks at the 1st, then 2nd, then 3rd. So 4 tries total, in the worst case.
    If it didn't break on the 4th, I'll try from the 7th floor now. If it does break, I'll spend another 2 tries, at most, to try at the 5th and 6th. So: 4 tries total, in the worst case.
    If it still didn't break at the 7th, I'll try at the 9th, with another try at the 8th in the worst case: 4 tries total.
    And if it still didn't break, I'll try the 10th.

    Applying the same principle to 100, I should try to drop the first egg along the following sequence of floors:
    14th, 27th, 39th, 50th, 60th, 69th, 77th, 84th, 90th, 95th, 99th.

    If the building was actually 105 stories high, I could determine whether an egg breaks when dropped from some floor, and at which floor, in only 15 tries, by continuing the sequence: .. 99th, 102th, 104th, 105th.

    ReplyDelete
  2. very interesting post.this is my first time visit here.i found so mmany interesting stuff in your blog especially its discussion..thanks for the post!
    diamond online

    ReplyDelete
  3. I recently came across your blog and have been reading along. I thought I would leave my first comment. I don't know what to say except that I have enjoyed reading. Nice blog. I will keep visiting this blog very often.
    different types of roof covering materials

    ReplyDelete
  4. Thank you very much for keep this information.
    Digital Painting

    ReplyDelete
  5. Love what you're doing here guys. keep it up!..
    digital drawing

    ReplyDelete
  6. Positive site. where did u come up with the information on this posting? I'm pleased I discovered it though. ill be checking back soon to find out what additional posts you include.
    photoshop drawing

    ReplyDelete
  7. I think this is an informative post and it is very useful and knowledgeable. therefore. I would like to thank you for the efforts you have made in writing this article.
    digital painting technique

    ReplyDelete