Lets devise a generic solution:

Let h(k,m) be the height that can be handled with k eggs and up to m drops.

Let the base at any time be the highest known safe floor. With k eggs and m drops left we can afford to skip h(k-1,m-1) floors and do our next drop at base + h(k-1,m-1) + 1.

When an egg breaks the base remains the same and both k and m decrease by 1.

If the egg doesn’t break, increase the base by h(k-1,m-1) + 1 and then decrease just m by 1.

So lets start with 1 egg and m floors :

h(1,m) = m

start dropping at the lowest floor and work upwards one at a time.So m attempts would be required.

h(2,m) =h(1,m-1)+1 +h(2,m-1)

=(m-1)+1+1+h(1,m-2)+h(2,m-2) and so on

So finally ,

h(2,m)=(m-1)+1 + (m-2)+1 + … + (m-m)+1 = SUM of m, m-1, m-2, …1 = m(m+1) / 2

h(3,m) =1+h(2,m-1)+h(3,m-1)

=1+ (m-2)(m-1)/2 + 1+ h(2,m-2)+h(3,m-2) and so on

So, h(3,m)=(m-1)m/2 +1 + (m-2)(m-1)/2+1 + … = SUM (1/2)j^2 – (1/2)j +1 for j from 1 to m and we get,

(1/12)m(m+1)(2m+1) – (1/4)m(m+1) + m = (1/6)(m^3 -m) + m = (1/6)(m-1)m(m+1) + m.

So , h(3,m)=(1/6)(m-1)m(m+1)+ m

For 120 floor building ,put m=1,2,3…. ans so on until u get a value greater than 120

8 drops is not enough but 9 drops would let us go as high as 120 + 9 which is enough.

# Resolving technical problems:

Solve your technical problems instantly

We provide Remote Technical Support from Monday to Sunday, 7:00PM to 1:00 AM

Mail your problem details at writeulearn@gmail.com along with your mobile numberand we will give you a call for further details. We usually attend your problems within 60 minutes and solve it in maximum 2 days.