You have test eggs and test parachutes.
You wish to determine the maximum height (in integer metres) that you can drop an egg + parachute at without the egg breaking before mass producing the parachutes.
The parachutes are single use, and the eggs can be used until they break.
You drop eggs + parachutes at integer metre heights until you have determined the maximum height or you run out of eggs or parachutes.
is the maximum determinable height, such that, if the egg's maximum height is one can guarantee they can determine with eggs and parachutes.
and for example.
Determine .
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
First one can note that n ( 0 , p ) = 0 = n ( e , 0 ) , n ( 1 , p ) = p , n ( p + a , p ) = n ( p , p ) = 2 p − 1 , for a ≥ 0 , the latter inequality being that we can do a binary search for x ∈ [ 0 , 2 p − 1 ] .
n ( e , p ) = ( n ( e − 1 , p − 1 ) + 1 ) + ( n ( e − 1 , p − 2 ) + 1 ) + . . . + ( n ( e − 1 , 1 ) + 1 ) + ( n ( e − 1 , 0 ) + 1 ) , as we can 1st test height ( n ( e − 1 , p − 1 ) + 1 ) , and if the egg breaks we run the method for e − 1 eggs and p − 1 parachutes on the ( n ( e − 1 , p − 1 ) discrete metres below.
Note, n ( 1 , p ) is of order O ( p 1 ) . n ( 2 , p ) is the sum of these, so is O ( p 2 ) . Similarly, we can see that n ( e , p ) is O ( p e ) .
Looking at a table of differences for n ( e , p ) across different values of p : p = 0 n ( e , 0 ) 1 n ( e , 1 ) 2 n ( e , 2 ) 3 n ( e , 3 ) . . . . . . e n ( e , e ) e + 1 n ( e , e + 1 ) . . . . . .
.
Using n ( p + a , p ) = n ( p , p ) = 2 p − 1 :
Δ 0 Δ 1 Δ 2 Δ 3 Δ e p = 0 2 0 − 1 2 0 1 2 1 − 1 2 0 2 1 2 0 2 2 2 − 1 2 1 ⋱ 2 2 2 1 2 0 3 2 3 − 1 2 2 . . . . . . . . . . . . . . . ⋮ 2 0 e 2 e − 1 2 e − 1 2 0 e + 1 . . . . . . . . . n ( e , e + 1 ) . . .
Because n ( e , p ) = O ( p e ) the Δ e row is all the same value, which will be 2 0 = 1 .
The equation for n ( e , p ) can be found by summing at the leftmost value of row Δ i multiplied by ( i p ) .
Hence, n ( e , p ) = ∑ i = 1 e ( i p ) .
n ( 5 , 1 1 ) = ∑ i = 1 5 ( i 1 1 ) = ∑ i = 0 5 ( i 1 1 ) − 1 = 2 2 1 1 − 1 = 1 0 2 3 .
One can also notice that ∑ m = 1 p ( n m ) = ( n + 1 p + 1 ) .
So induction can be used to get n ( e , p ) = ∑ i = 1 e ( i p ) , using the base case n ( 0 , p ) = 0 and using n ( e , p ) = [ ∑ i = 0 p − 1 n ( e − 1 , i ) ] + p .
Inductive step: assuming n ( k , p ) = ∑ i = 1 k ( i p ) for all p , n ( k + 1 , p ) = [ ∑ i = 0 p − 1 n ( k , i ) ] + p = [ ∑ i = 0 p − 1 ∑ j = 1 k ( j i ) ] + p = [ ∑ j = 1 k [ ∑ i = 0 p − 1 ( j i ) ] ] + p = [ ∑ j = 1 k ( j + 1 p ) ] + ( 1 p ) = ∑ j = 1 k + 1 ( j p ) .