I am trying to write a program in Python for the famous egg drop puzzle using recursion. If you don't know the problem statement, here it is:

https://code.google.com/codejam/contest/dashboard?c=32003#s=p2

One solution to this puzzle would be to use a recursive function that returns the maximum number of floors in a building that would allow $ Solvent (F, D, B) $ to be true, represented as such, as a function $ f $:

$ f (D, B) $ $ = $ $ 1 $ $ + $ $ f (D – 1, $ $ B – 1) $ $ + $ $ f (D – 1 $, $ B) $

… or $ D $ is the number of drops remaining, and $ B $ is the number of breaks allowed. This solution uses how an egg can break $ f (D – 1, $ $ B – 1) $ lower floors, and $ f (D – 1 $, $ B) $ floors above.

As you can see, this results in the formation of a binary recursive function as shown above. Combined with the fact that we know that $ f (1, B) $ $ = $ $ 1 $ for all values of $ B $, and how $ f (D, 1) $ $ = $ $ D $ for all values of $ D $, this should not be a problem for a program that can handle recursion very well. However, Python has the gift of being unable to handle recursion as well as some other languages.

As such, I would like to know if the maximum number of floors returned by the function $ f $ can be determined for a set of values where $ 1 <= D, B <= $ 200,000,000 in Python.

Here is a list of techniques that I have tried so far, to no avail:

1. Memoisation (caching of values of $ f (D, B) $)

2. Since we know that $ f (d, b) $ for $ d <= b $ is equal to $ f (d, b) $ or $ d = b $, with $ d $ kept constant we can reduce the number of pairs of $ d $ and $ b $

3. When $ d = b $, $ f (d, b) $ is equivalent to $ 2 ^ d – $ 1, thereby removing the need for binary recursion for $ d = b $