<p>With m eggs and k measurements the most floors that can be checked is exactly $$n(m,k)={k \choose 0} + {k \choose 1} + \ldots + {k \choose m},$$ (maybe $\pm 1$ depending on the exact def). Proof is trivial by induction. This expression has no closed form inverse but gives good asymptotic.</p>

CC BY-SA 3.0
2012-12-10T23:58:51.183Z
Just sketching the dropping strategy a little would make the answer more complete. Maybe it's not appropriate, since I guess it's not research-level. Anyway, with 2 eggs, you can skip $k$ floors on your first drop, and if it doesn't break, skip $k - 1$, and if it doesn't break skip $k - 2$, etc. Which gives $k(k+1) / 2$ as the highest floor you could reach using this strategy.
Joe
CC BY-SA 3.0
2012-12-11T13:45:27.453Z
@domotorp It seems constructive to examine the puzzle from the perspective you have just shown. And the equation about $n(m,k)$ can be proved by induction on $m$ and $k$. Although there is no clear closed form for the right hand side of this equation, can it give the asymptotic expression $k(n,m) = \Theta(n^{\frac{1}{m}})$?
hengxin
CC BY-SA 3.0
2012-12-11T13:51:10.623Z
@hengxin, yesish, because $\binom{k}{m}$ is a polynomial in $k$ of degree $m$, so this shows that holding $m$ constant gives $n(m, k) = \Theta(k^m)$. But see Robin's comment on the question. The more interesting question is whether this exact expression allows a more precise bound by approximating the binomial tail e.g. with erf.
Peter Taylor
CC BY-SA 3.0
2012-12-10T10:56:05.957Z
2012-12-10T10:56:05.957Z
domotorp
<p>In my comment above I said perhaps $\Theta(\min_{k \le m} kn^{\frac{1}{k}})$ is a tight bound. I'm not sure about the lower bound, but since you just want an explanation for what $k$ means, I can explain the intuition using the upper bound.</p>

<p>As you guessed, $k$ is the number of eggs actually used. That explains the $\min$ on the outside. Now once we've decided to use $k$ eggs, here's a strategy that works: Think of the number $n$ as being written out in base $n^{1/k}$. So $n$'s representation will have $k$ "digits" (the word "digit" is usually reserved for base 10, but I'll use it here), and each digit holds a value from 0 to $n^{1/k}-1$. With our $k$ eggs, we're trying to extract the digits of $n$ one by one. First we start with the most significant digit. This can be determined by throwing an egg from the floor numbered $100..00$, $200..00$, and so on. After at most $n^{1/k}-1$ throws, we've learnt what the most significant bit is, and in the worst case we've broken only 1 egg. Now we do this for all the other digits. Since there are $k$ digits, we'll need $O(kn^{1/k})$ throws.</p>

<p>As a sanity check, observe that when $k=1$, this strategy boils down to dropping eggs from each floor one by one starting from floor 1. When $k = \log n$, we're just working in base 2. So this yields the binary search algorithm. </p>

CC BY-SA 3.0
2012-12-12T04:12:03.523Z
An interesting feature of domotorp's solution, unlike yours, is that it does not require knowing n in advance!
Jeffε
CC BY-SA 3.0
2012-12-12T03:35:39.693Z
2012-12-12T03:35:39.693Z
Robin Kothari
<p>The following brief description of the known "Google Eggs Puzzle" comes mainly from the web site <a href="http://standardwisdom.com/softwarejournal/2010/10/puzzles-and-answers/">Google Eggs</a>:</p>

<blockquote>
  <p><em>Google Eggs Puzzle:</em> Given n floors and m eggs, what is the approach to find the highest floor from which eggs can be thrown safely, while minimizing the throws (not broken eggs). </p>
</blockquote>

<p>The so called "highest floor" in the above problem deserves more formal definition:</p>

<blockquote>
  <p><em>"highest:"</em> there must be a floor <em>f</em> (in any sufficiently tall building) such that an egg dropped from the <em> f </em>th floor breaks, but one dropped from the (<em>f-1</em>)st floor will not. Then, <em>f-1</em> here is the highest floor.</p>
</blockquote>

<p>Actually, the description of "highest" is an excerpt from the book "The Algorithm Design Manual (Second Edition)" by Steven S. Skiena. Being an exercise in Chapter 8 "Dynamic Programming", there are plenty of resources in Web devoted to solving the puzzle by the means of dynamic programming, like <a href="http://standardwisdom.com/softwarejournal/2010/10/puzzles-and-answers/">Google Eggs</a> and <a href="http://www.datagenetics.com/blog/july22012/index.html">The Two Egg Problem</a>.</p>

<p>However, there is a question from the above book:</p>

<blockquote>
  <p>Show that $E(n, m) = \Theta(n^{\frac{1}{m}})$, where $E(\cdot)$ is the minimum number of throws. (Note: I have changed the notations used in book for consistency.)</p>
</blockquote>

<p>It is the question that motivates my problem:</p>

<blockquote>
  <p><strong>My Problem:</strong> Is there some mathematical closed form for general "Google Eggs Puzzle" with n floors and m eggs, instead of dynamic programming recurrence, and of course tighter than the $E(n, m) = \Theta(n^{\frac{1}{m}})$ one? </p>
</blockquote>

CC BY-SA 3.0
2012-12-09T15:40:27.853Z
I don't think the asymptotic bound is tight. It works when $m$ is a constant, but if you take $m = \log n$, your bound gives you a constant, which is false. I think a tight bound is $\Theta(\min_{k\leq m} kn^{1/k})$, which reproduces your bound for constant $m$, but also gives $\log n$ as the number of throws when $m$ is large enough to support the naive binary search based strategy.
Robin Kothari
CC BY-SA 3.0
2012-12-12T01:23:19.043Z
@RobinKothari I agree with you. The numerical experiments in the material [Joy of Egg-Dropping](http://archive.ite.journal.informs.org/Vol4No1/Sniedovich/) support your observation. However, I don't catch the meaning of $\Theta(\min_{k \le m} kn^{\frac{1}{k}})$. As my guess, the parameter $k$ is the _actual_ number of eggs in use. Then, what does it mean as a factor in $kn^{\frac{1}{k}}$ ? Thanks a lot.
hengxin
CC BY-SA 3.0
2012-12-12T03:36:05.870Z
I can try to explain the meaning, but it's a bit long so I'll post it as an answer.
Robin Kothari
<ds.algorithms><puzzles><dynamic-programming>
Is there some mathematical closed form (or somewhat tight asymptotic one) for "Google Eggs Puzzle"?
hengxin
# Is there some mathematical closed form (or somewhat tight asymptotic one) for "Google Eggs Puzzle"?

(Asked by: username_0 on 2012-12-09)

The following brief description of the known "Google Eggs Puzzle" comes mainly from the web site [Google Eggs](http://standardwisdom.com/softwarejournal/2010/10/puzzles-and-answers/):

> *Google Eggs Puzzle:* Given n floors and m eggs, what is the approach to find the highest floor from which eggs can be thrown safely, while minimizing the throws (not broken eggs).

The so called "highest floor" in the above problem deserves more formal definition:

> *"highest:"* there must be a floor *f* (in any sufficiently tall building) such that an egg dropped from the  *f* th floor breaks, but one dropped from the (*f-1*)st floor will not. Then, *f-1* here is the highest floor.

Actually, the description of "highest" is an excerpt from the book "The Algorithm Design Manual (Second Edition)" by Steven S. Skiena. Being an exercise in Chapter 8 "Dynamic Programming", there are plenty of resources in Web devoted to solving the puzzle by the means of dynamic programming, like [Google Eggs](http://standardwisdom.com/softwarejournal/2010/10/puzzles-and-answers/) and [The Two Egg Problem](http://www.datagenetics.com/blog/july22012/index.html).

However, there is a question from the above book:

> Show that $E(n, m) = \Theta(n^{\frac{1}{m}})$, where $E(\cdot)$ is the minimum number of throws. (Note: I have changed the notations used in book for consistency.)

It is the question that motivates my problem:

> **My Problem:** Is there some mathematical closed form for general "Google Eggs Puzzle" with n floors and m eggs, instead of dynamic programming recurrence, and of course tighter than the $E(n, m) = \Theta(n^{\frac{1}{m}})$ one?

**Tags:** ds.algorithms, puzzles, dynamic-programming
> **Comments:**
> **username_1**: I don't think the asymptotic bound is tight. It works when $m$ is a constant, but if you take $m = \log n$, your bound gives you a constant, which is false. I think a tight bound is $\Theta(\min_{k\leq m} kn^{1/k})$, which reproduces your bound for constant $m$, but also gives $\log n$ as the number of throws when $m$ is large enough to support the naive binary search based strategy.  
> **username_0**: @RobinKothari I agree with you. The numerical experiments in the material [Joy of Egg-Dropping](http://archive.ite.journal.informs.org/Vol4No1/Sniedovich/) support your observation. However, I don't catch the meaning of $\Theta(\min_{k \le m} kn^{\frac{1}{k}})$. As my guess, the parameter $k$ is the _actual_ number of eggs in use. Then, what does it mean as a factor in $kn^{\frac{1}{k}}$ ? Thanks a lot.  
> **username_1**: I can try to explain the meaning, but it's a bit long so I'll post it as an answer.  

---

## 2 answers

### Answer by username_2 on 2012-12-10. Score: 8 | Accepted answer

With m eggs and k measurements the most floors that can be checked is exactly $$n(m,k)={k \choose 0} + {k \choose 1} + \ldots + {k \choose m},$$ (maybe $\pm 1$ depending on the exact def). Proof is trivial by induction. This expression has no closed form inverse but gives good asymptotic.

> **Comments:**
> **username_3**: Just sketching the dropping strategy a little would make the answer more complete. Maybe it's not appropriate, since I guess it's not research-level. Anyway, with 2 eggs, you can skip $k$ floors on your first drop, and if it doesn't break, skip $k - 1$, and if it doesn't break skip $k - 2$, etc. Which gives $k(k+1) / 2$ as the highest floor you could reach using this strategy.  
> **username_0**: @domotorp It seems constructive to examine the puzzle from the perspective you have just shown. And the equation about $n(m,k)$ can be proved by induction on $m$ and $k$. Although there is no clear closed form for the right hand side of this equation, can it give the asymptotic expression $k(n,m) = \Theta(n^{\frac{1}{m}})$?  
> **username_4**: @hengxin, yesish, because $\binom{k}{m}$ is a polynomial in $k$ of degree $m$, so this shows that holding $m$ constant gives $n(m, k) = \Theta(k^m)$. But see Robin's comment on the question. The more interesting question is whether this exact expression allows a more precise bound by approximating the binomial tail e.g. with erf.  

---

### Answer by username_1 on 2012-12-12. Score: 2

In my comment above I said perhaps $\Theta(\min\_{k \le m} kn^{\frac{1}{k}})$ is a tight bound. I'm not sure about the lower bound, but since you just want an explanation for what $k$ means, I can explain the intuition using the upper bound.

As you guessed, $k$ is the number of eggs actually used. That explains the $\min$ on the outside. Now once we've decided to use $k$ eggs, here's a strategy that works: Think of the number $n$ as being written out in base $n^{1/k}$. So $n$'s representation will have $k$ "digits" (the word "digit" is usually reserved for base 10, but I'll use it here), and each digit holds a value from 0 to $n^{1/k}-1$. With our $k$ eggs, we're trying to extract the digits of $n$ one by one. First we start with the most significant digit. This can be determined by throwing an egg from the floor numbered $100..00$, $200..00$, and so on. After at most $n^{1/k}-1$ throws, we've learnt what the most significant bit is, and in the worst case we've broken only 1 egg. Now we do this for all the other digits. Since there are $k$ digits, we'll need $O(kn^{1/k})$ throws.

As a sanity check, observe that when $k=1$, this strategy boils down to dropping eggs from each floor one by one starting from floor 1. When $k = \log n$, we're just working in base 2. So this yields the binary search algorithm.

> **Comments:**
> **username_5**: An interesting feature of domotorp's solution, unlike yours, is that it does not require knowing n in advance!  

---

