April 3rd, 2008

Interview Questions: Two Bowling Balls

This post is the first in a series I’m calling “interview questions,” where I discuss interview questions I’ve been handed in my time out here in the Bay Area. Since I’m an engineer by trade most of the questions relate directly to technical topics. I’ll also cover general interview strategies and advice — probably by serving myself up as an example of what not to do in an interview.

I know people keep a repertoire of interview questions at hand, so I’m not going to name names when discussing the questions. Anyhow, let’s get started!

The Question

You’re standing in front of a 100 story building with two identical bowling balls. You’ve been tasked with testing the bowling balls’ resilience. The building has a stairwell with a window at each story from which you can (conveniently) drop bowling balls.

To test the bowling balls you need to find the first floor at which they break. It might be the 100th floor or it might be the 50th floor, but if it breaks somewhere in the middle you know it will break at every floor above.

Devise an algorithm which guarantees you’ll find the first floor at which one of your bowling balls will break. You’re graded on your algorithm’s worst-case running time.

Warning: Stop reading here if you’re not interested in seeing any of my solutions!

A Few Preliminaries

The original problem stated that the building had 100 floors, but it may as well have N floors. Using N rather than 100 will make it easier to quantify the performance of the algorithm, so that’s what I’m going to do.

Solution 1: The Naïve Solution

Ok, there’s one blindingly obvious solution: take one of the bowling balls and drop it from every floor, starting from the first. At worst this will take N tries, where N is the number of stories on the building.

Interview Advice:: In an actual interview situation don’t be afraid to say the obvious solution, even if you know there’s a better one. Problem solving is iterative and your answer should be, too.

Solution 2: Two Bowling Balls

We know the first solution is probably sub-optimal because it doesn’t make use of both bowling balls. To give us some ideas let’s just pick a floor, say the 50th floor, and drop one of the balls — we has nothing to lose since we know we can do it with only one.

If our building is 100 floors and we dropped one of the balls from the 50th floor one of two thing will happen: the ball will either break or it won’t. If it breaks then we know the floor we’re looking for is somewhere between floors 1-49. If it doesn’t then we know it’s somewhere between floors 51-100. In either case we’ve halved the size of the search space and now need at most N/2 (or 50) tries.

But 50 was arbitrary. What about other numbers? What happens if we drop the ball on the third floor? If it breaks then we can use the second ball to test floors 1-2, taking at most 3 tries. If it doesn’t break then we try the same experiment again, dropping the ball from another floor.

Here’s one possible strategy: pick a number S and call it the skip number. We drop one ball every S floors until it breaks on the kth try. We then use the second ball to try every floor between floors (k-1)*S and k*S.

As an example, let N=100 and S=4. We’d try floors 4,8,12,16,… with one bowling ball until it breaks. Let’s say it breaks on the 60th floor. Since it didn’t break on the 56th floor we know the culprit is somewhere on floor 57, 58, 59, and we can use the second ball to test those floor one at a time using the naïve strategy.

What is the best skip size? Obviously S=100 isn’t ideal since that is equivalent to the naïve strategy, as is S=1. But we know both S=50 and S=4 are better, so there must be an optimal strategy somewhere between. To find this strategy let L(S) be the number of drops requires in the worst-case scenario for a skip number of S. If you work it out you’ll get

We want to minimize this function. Bringing back our high school calculus, the derivative of L(S) is

Setting the derivative equal to zero implies

For N=100 this gives an optima skip of S=10. If N isn’t a perfect square you’ll have to work out which skip gives the “correct” solution.

Solution 3: You can do better…

At this point in the interview you’re probably pretty happy with yourself. The above took you a few minutes to work out, perhaps with some prodding by the interviewer. But then you hear that dreaded question, “Can you do any better?”

The interviewer isn’t a jackass, though, and gives you a hint. He points out that it seems like we should be able to find a solution that works equally well irrespective of where the bad floor is. That is, it should take the same number of turns if its on the 100th floor as it would if it were on a lower floor.

We have a baseline for ourselves. For N=100 and S=10 we know we can do it in at most 19 turns. This can act as a sort of counter — if we beat this number at every step we’ve come up with a strictly better algorithm. So, at every step, we want to be able to find the floor in question in no more than 18 steps.

Let’s start by dropping the first ball on the 18th floor. If it breaks we can test floors 1-17 with the second ball, taking at most 18 turns. If it doesn’t break, we’ve used up one of our turns, leaving us with 17 turns left.

So, the next floor we should test is 18+17, or the 35th floor. If it breaks we can test floors 19-35, taking at most 18 turns. We can continue this way, shrinking the step size by one each time. Now we know we can do it in at least 18 steps.

But why not 17? If we repeat the above steps, starting with a counter of 17 rather than 18, we get an algorithm that takes at most 16 steps. Then, using 16 as a counter, we get an algorithm that takes at most 15 steps. We can’t do this forever, since there’s no possible algorithm that takes at most one step. So where is the end of the line?

The problem is that for this algorithm to work the first ball needs to be able to skip one fewer each time and still cover all 100 floors. If we set our counter to C that means we must have 1+2+…+C > 100.

Here’s the math:

Using the quadratic formula to find the exact solution and then taking into account the fact that we want an integer solution gives

as the worst possible case for our third strategy. L(100) = 14, which checks out.

That’s the best solution I know, and it was the best solution the interviewer knew, too. Can you do any better?

After The Interview

This was one of a few questions I was asked by one of four interviewers. I worked through the problem above, basically as it was written out, albeit with more digressions. How did the interview wind up going? I wasn’t offered a job. At least I got a good interview question out of it, though.

  • ken vh
    I couldnt help myself and went ahead and found the optimal strategy under the (not unreasonable) assumption of uniform distribution. The 14 strategy outlined above is the best worst case, but it will always take 14 tries. The following sequence of skips has the optimal expected tries of around 12.84--not much of an improvement--with worst case 19:

    10, 9, 9, 8 ,8 ... 3, 3, 2, 2, 1, 1
  • Yeah, the idea is that the person placing the light bulb is actively working against you and knows your strategy beforehand.

    Can you share the math that gave you those numbers? I'd be interested in taking a look.
  • RAR RAR FIGHT THA POWA
    awwwww... butthurt?
  • maxvinland
    Why would he be? According to the parameters set out by the interviewer his solution is still 5 tries better.

    Don't make a mean comment if you don't know what's going on.
  • Andrew
    The problem gets more interesting if you have 3 balls, 4 balls, etc. I believe

    for 3 balls, n = 100, the first floor should be 36. 8 * 9 / 2!, max 8 tries
    for 4 balls, n = 100, the first floor should be 56. 6 * 7 * 8 / 3! max 6 tries
    for 5 balls, n = 100, the first floor should be 70. 5 * 6 * 7 * 8 / 4! max 5 tries
  • Chris L.
    Those are some intelligent, logical solutions you've provided. Kudos on your cleverness and ability to figure that out on the spot in an interview setting.

    I probably would have turned the question around on the interviewer and asked how resilient the bowling ball needed to be? Did it need to survive 10 floors? 15? Why were we doing the resiliency test in the first place? Developers who take the requirements at face value without understanding the motivation aren't nearly as valuable as the ones who can see past what is being asked for and find a simpler solution that delivers the underlying need.

    If it turned out we just needed it to survive falling from 15 stories, I would have dropped one ball from the 15th floor window and if it survived it passed our test otherwise it didn't. One step, and we save a ball.
  • I like the variation where there’s no elevator. How does it change if you have to walk up the stairs each time you drop the ball, and you want to minimize the total number of flights of stairs you have to climb up? What if you can only carry one ball at a time? What if you can carry both balls at the same time?
  • X
    These kind of interview questions are retarded
  • I don't think that word means what you think it means.
  • Word Nazi
    I don't think that you don't think you know what he was saying, and at mutual understanding that word means what he thinks it means.
  • One "Special" Guy
    nope.. I pretty much agree. This problem is retarded.

    Put the ball it in a vise where you can measure the force when the ball breaks. Calculate the velocity required to reach that force and subsequent height needed. Then A) go bowling or B) sell the second one on ebay.

    So this is a legitimate answer. You (as interviewer) say we should take the problem at face value and devise an algorithm to solve it. Me: Ok that's cool. I then tell you the problem isn't really solvable then because the bowling ball will accumulate damage as we test it (as others have pointed out). Me: OK (rolls eyes internally)
    I solve problem again this time assuming changing floors and retrieving the ball is very time consuming (I don't know... like a database call, or a disk read... that doesn't have anything to do with computers either I guess). You again tell me I'm "wrong" because I didn't guess how you wanted me to solve this. (At this point I don't want your f'ing job anyway but decide to trudge through this retardation anyway (that's right because this interview is actually killing brain cells and making me think slower)) Alright now I go through the process you've gone through, get the "right" answer, and try to get the hell out of your office before the stink of failure rubs off on my clothes. The interviewer is annoyed it took me so long and I'm pissed off that I've wasted half of my day with your crappy company.
  • You sound pretty anti-social.
  • One "Special" Guy
    I don't think that word means what you think it means.
  • Zing.
  • Piotr
    You can find the lower bound here: http://www.cs.umd.edu/~gasarch/BLOGPAPERS/egg.pdf
  • enkidu
    What if your ball breaks while you're testing? If you have no replacements, then you can only
    skip one floor at a time, for a worst case of 51 ball drops. If have a big supply of spares, then
    I must be missing something. Why not just do a binary search? If you're only measuring the
    number of dropped balls, it's O(log2(N)). For N=100, you only need 7 ball drops.
  • That's the whole point of the problem, really. You have two bowling balls. Some tests might cause them to break.

    How do you find the first floor where they do break?
  • enkidu
    OK, I didn't read it through. I agree with the analysis. Is there anyway to delete my comment?
  • socrates
    You don't consider the timing factor. It takes (much) more time to climb to higher floors. And, more time to drop (not so much).

    You say: "You're graded on your algorithm's worst-case running time. ", but you're optimizing on # of tries, which does not = time unless you account for actual time, not just # of tries.
  • There's a version with stairs, where the time to climb is taken into account, and there's a version with an elevator or other "cost-free" form of transportation. This one is the latter, and it's the one the interviewer was asking about.
  • Jordan
    The problem is that if you drop the ball and it doesn't break then you have a damaged ball. You're measuring resilience based on accumulated damage not resilience based on a fresh ball.

    If you can drop the ball without it being damaged then it will never break.

    It's an inherently flawed question if they require you to use only two balls. Ideally you'd need a fresh ball for each drop.
  • It's a math problem disguised as a story. The story doesn't need to be literal if you can still understand it.

    Maybe the bowling balls are coated in a self-repairing layer of nanites, which stop working if the ball shatters.
  • gwenhwyfaer
    Nonetheless, it's probably worth mentioning as a real-world constraint that can stymie even the best of theoretical solutions. We all know how often that happens, after all. :)
  • utsuprainfra
    I guess you're right, but it would be a very strong answer to point out Jordan's point, as well as the manufacturer's information, etc., before going into your math logic.
  • Leo
    Why not try some kind of binary-search-like algorithm? For example, say the true value at which it would first begin to break is floor 61. Test length/2, which is 50. Does it break? No, so reject all floors below 50. Test 75; breaks, reject > 75. Test 63; breaks, reject > 63. Test 57; no break, reject < 57. Test 60; no break, reject < 60. Test 62; breaks, reject > 62. Test 61; if it breaks, you have the true value, else it is 62. That's 7 tests. If the true value is 100, it takes 6 steps (I think). Did I read the problem wrong?
  • Leo
    public static void main(String[] args)
    {
    int length = 100;
    for (int i = 0; i < length; i++)
    {
    int realValue = i;

    boolean[] floors = new boolean[length];
    for (int n = 0; n < realValue; n++)
    {
    floors[n] = false;
    }
    for (int n = realValue; n < length; n++)
    {
    floors[n] = true;
    }

    int tests = 0;
    int start = 0;
    int end = length;
    int testPoint = 0;
    while (end - start > 1)
    {
    testPoint = (end - start) / 2 + start;
    if (floors[testPoint])
    {
    end = testPoint;
    }
    else
    {
    start = testPoint;
    testPoint = end;
    }
    tests++;
    }

    System.out.println("True value: " + testPoint);
    System.out.println("Tests: " + tests);
    }
    }
  • utsuprainfra
    IF it does break at 50, you're screwed. Worst case is like 49.
  • Leo
    With the true value at 50 it turns out to be 7 tests, which is the worst case. 6 tests is the best case =). At least, that's with the code above. I'm not sure if there's some subtlety with starting the floors and true value at 0 or 1 or what.
  • Mike
    If you had log2n bowling balls, binary search would be optimal. But if one breaks at 50, then the other one breaks at 25, you haven't found where it breaks, other than "less than 25".
  • Leo
    Yep. Guess I should have read the problem description more carefully =)
  • Azn
    You tell the interviewer that a mathematical solution isn't always required, and for the first preliminary round you use your gut feeling to pick an approximate floor and throw it out the window. If it breaks, whoopie, the ball isn't as tough as you think, and if it doesn't, its tougher than you think. Either way, you got a ballpark based on your gut feeling.

    In real life, a bowling ball will NOT survive a 100 floor drop. It just isn't possible. So you can discount the 100th floor. 99th? Discount it too. Repeat until you feel that the bowling ball is likely to survive. There is no point testing at any floor above that if you're sure the results aren't what you're looking for.

    This question is akin to asking an undergraduate engineer what voltage a resistor will take, and then in demonstration, a far lower voltage would have burnt out the resistor already. Mathematics is fun, but in engineering, real life is what matters.
  • Alex S
    Is't there a case where it takes 15 tries?

    In the strategy above we're dropping the first ball from floors 14, 27, 39, 50, 60, 69, 77, 84, 90, 95. Suppose it does not break on any.

    After that there are 5 unexplored floors left, 96,97,98,99,100. We've used up 10 tries already, which means that worst case it will take 15 to find the remaining one.
  • Alex S
    Oh wait, 99, doh.
  • IConrad
    This is, of course, on Reddit. A gentleman there (not me) had the conniving idea of getting a lower bound not by trial but by additional data request: ask the manufacturer what the physical standards are for the ball.

    Your algorithm is numerically sound, but that //would// be a "cheating" way to get the job done that would be more highly optimized.

    Is it a hack? Sure. But it's a 'legitimate' hack -- and might have represented a similar way of thinking to the "get the cup without walking on the carpet" problem.
  • utsuprainfra
    I would have hired you. Why do you think they didn't?
  • Outwood
    LOL< dude that is totally insane!

    http://www.anonymity.at.tc
  • REd
    DUMB ASS - if you are hiring me to do things with bowling balls I am definitely in the wrong building ... I thought you wanted a programmer...here let me show you what you can do with 2 bowling balls...oh btw when i throw you off the freaking building at what point will you realize YOU ARE A DUMB ASS - you and all the DUMBASSES who read REDdit and think you are not DUMBASSES - well - YOU ARE
  • You realize this is a question someone asked me, right? Not one that I've asked someone else.

    Even so, I like it more than most silly puzzle questions because there's a clear naive solution and a steady progression of solutions from poor to best.
  • Paul
    My solution is to start at the tenth floor and drop a ball at each floor, increasing by ten. If the ball break, go back 9 floors and go up by one. That gives you O(2 * log10(n)). It's not the best for efficiency, but it is simple enough to explain to someone who doesn't have a college education, which makes it very desirable. Loops as follows:

    i = 0
    while( i < log10(n) and testFloor( (i + 1) * log10(n) ) {
    i = i + 1
    }
    j = ( i * log10(n) ) + 1
    while( j < i and testFloor(j) ) {
    j = j + 1
    }
    return j * i

    The pattern, I'm sure, can be improved. I was just exploiting that it is guaranteed to be within a 2 digit number. So one ball to figure out each digit.
  • Ron Stewart
    RTFM - If you want to code for the rest of your life give the answers above.
    If you want to be the one managing coders then ask them to read the bowling ball manual !
  • Who would work at a place that asked such a ridiculous interview question?
  • About 500 people, last count. It was Facebook.
  • skitzo
    I don't know if I want to take interview advice from a guy who didn't get the job.
  • *shrug*
  • Yishan
    Oh, that was at Facebook. We [used to] ask that question, and have teams of 4 interviewers, but didn't hire you. Let me know if you want to take another shot, though it looks like you're doing pretty well with Adnomics.
  • Hey Yishan,

    Thanks for the offer. A year and a half ago I might have taken you up on that, but Facebook has changed too much and so have I.

    - Jesse
  • Good Job
    Can't believe they never gave you the job. Idiots
  • Read here if you want to know why: http://20bits.com/articles/when-its-your-turn/

    I only blame myself, although in retrospect I'm glad I didn't get it.
  • Scott
    When thinking about how to improve upon this method for testing bowling balls, it seems more efficient to carry two balls up with you for each state of the testing, dropping one after the other on different floors, to save on the trip down. After all, pitching one out the 10th floor and one out the 20th requires only twenty floors of travel, not thirty transporting them individually.
  • Meneer R
    You failed.

    You were being judged on the WORST CASE.
    If you choose to use 2 balls, the worst case is 100 throws plus one (the extra ball you had to throw from floor 100)
    If you choose to use just one ball, the worst case is 100 throws.

    There, solved it for ya.

    And because you went all complex on this trivial logic excersize is likely why you didn't get the job.
  • Meneer R
    Let me rephrase that: you and others here did not solve the original problem.

    You went looking for an optimal solution, if you would solve this problem a 100 times, with the balls breaking on a different floor each time.
    You clearly state in the beginning that you were suppose to solve the problem of the WORST CASE. Which is just (n); using one ball.

    You never told the interviewer that. You went on to solve a different problem. The one you were not asked to solve.
  • Kapow
    "You're graded on your algorithm's worst-case running time."

    Your algorithm's worst-case is 100. His last algorithm's worst-case is 14. A shorter running time is better, of course.

    You have the worst possible worst-case running time. Not only did you fail, you failed as hard as you possibly could.
  • Meneer R
    Correction:
    If you choose to use 2 balls, the worst case is 100 throws

    You can, with two balls, have the same optimum solution as with one ball, off course. Just keep switching them ;-)
  • Meneer,

    If you read the post, the naive solution of using one ball and going one floor at a time is the first one given. The interviewer was happy with the solution.
  • Mat
    Ummm... I don't understand a lot of above BUT, BUT, BUT.... surely you don't need to include any floors above that which throwing the ball from would allow it to achieve achieve terminal velocity...
  • I don't understand what it means, therefore I am confused by this!
  • rdoggett
    I give up. I've a neat little program, but every time I try to post, it comes out a huge pile of garbage. I can't even figure out how to delete the garbage posts, but fortunately they don't seem to show up here. This problem stumped me in a Google interview. It's fun and easy to write a program that solves it recursively. If I can figure out how to post successfully, I'll publish my code.
  • I enjoyed reading this and am very impressed with how you came to the conclusion. Makes me wish I could do that kind of math. Because it was an engineering job interview is it assumed that the context is not real world? Funny how engineers love to phrase things in real world terms to give it a facade of real world. If this were a real world situation I don't think you could conduct the test and get accurate results with two balls. Each time a ball is dropped it is weaken and is not the ball it was before that drop. A ball receiving it's first drop from any floor would be less likely to break than a ball which had already suffered several violent impacts. A ball dropped twice from any floor might break on the second drop, the damage is cumulative. I mean this in a friendly, humorous way; I would worry about the common sense of the interviewer and of any interviewee who didn't blurt that out right away. The two ball limitation is specified in the question but whatever number of drops you come up with you would have to have that many identical test balls.
  • That's a math question not a programming question. It's not relevant at all, but people love giving them anyway. Has anyone ever quantitatively proven that asking math questions to programmers leads to hiring the best programmer?
  • Biff Tardisblue
    If you only have two balls, probability will prevent you from completing any of these prosposed solutions, as both balls will be destroyed before the answer is found.
  • Not true. You are guaranteed to find a solution by going one floor at a time with one ball. But can you do better?
  • Biff Tardisblue
    Yer so clever! you get 4 gold stars today. It's interesting to see all the erroneous assumptions posited here. I give, what's the answer?
  • I outline the steps in the article.
  • Rick Spencer
    Obviously the point of the question is to get a sense of the prospect's mathematical reasoning ability. That said, before working out algorithms, I'd expect a pragmatic programmer to ask things like:

    1. Can't he manufacturer just tell us, so we can store the value and retrieve it as needed?
    2. Can we copy the bowling balls, and then use an existing binary search function?
    3. Has anyone else done this? Is there a library that we can use?
    4. Etc ...

    In other words, how can we avoid having to solve the problem ourselves if we don't have to?

    Cheers, Rick
  • Excellent article, very thought-provoking.

    I cannot help but wonder if, by presenting the article in story format (and not as a purely abstract mathematical problem), the interviewer was inviting you to consider real-world implications such as the damage done to each ball when dropped, terminal velocity, etc. Especially if the job was for a programmer, who'd be familiar and comfortable with more abstract problems.

    As one previous comment suggested, sometimes it's more difficult to find a programmer who understands the business rules than it is to find someone who can devise an efficient, mathematically sound algorithm. I've seen programmers spend hours and wrack their brains coming up with elegant, sophisticated "solutions" that overlook simple, common-sense factors. No offense intended, but programmers, IT specialists, and INTP-types are sometimes guilty of dwelling on theory at the expense of practice...
  • Jarrod,

    No, that wasn't the reason. If anything it was the opposite. The rest of my interview didn't inspire enough technical confidence, and I spent my time asking questions about their business. Read here for the details: http://20bits.com/articles/when-its-your-turn/

    The reason I received for not getting an offer was that I, quote, "didn't have a strong enough technical background."
  • Ali Pang
    I don't see why you have the equality C + (C-1) + ... + 1 > N strict here. Dropping a ball at a level C gives you an inclusive upper bound in the resilience-height of the ball.

    Secondly: You ponder the existence of a better solution. Would you not be able to easily prove this is optimal? This is worst-case analysis so we can take on the role of the adversary when considering alternative algorithms.

    Clearly there exists a smallest integer C s.t. C is the lowest possible number of tries you have to make.

    Claim:
    Dropping the ball on height C in the first step is optimal.
    Proof:
    If an alternative algorithm chooses to drop it lower, we just place the actual place the ball breaks higher. Then in the next step the alternative would have to solve something >at least< as hard.
    If an alternative algorithm chooses to drop it higher, then just place the ball in the last spot the algorithm would look with the remaining ball. (Remember we can be psychics when placing the ball here.) This would result in a >worse< number of tries.

    Repeating this argument in each step proves that your strategy is optimal.
  • Alcari
    You missed something potentially usefull.
    Setting the upper limit where you can stop testing.

    Step 1 -- Calculate terminal velocity, using size and weight (for example, say thanks to wikipedia, example uses maximum weight), guesstimating drag coefficient at .47 for a smooth sphere.

    -1/2 (rho) * v^2 * A * Cd = m * g
    -1/2 1.3 * v^2 * pi*(0.108)^2 * 0.47 = 7.2 * 9.81
    0.0112 * v^2 = 70.6
    v ~ 79.40 m/s

    Step 2 -- Determine fall distance at which terminal velocity is achieved
    79.4 m/s is reached after 79.4 / 9.8 = 8.1 seconds

    d = 1/2 * g * t^2
    d = 1/2 * 9.8 * 8.1^2
    d = 321.65 meters

    So, depending on the dimensions of the building (and of course, the weight of the bowling ball), you can skip the top few floors. If it's a children's ball (weight 6 pounds or 2.72 kg), the max required test height is only 121 meters, or roughly 40 floors. Depending on your ball, a little physics will do wonders for the number of tests.

    With a light ball, even your Method 1 will solve the problem in 10 steps, if only you used some physics first.
    You can do even better by calculating at which height the ball will break. That way, assuming you have reasonably accurate figures, you can do it in 3 or 4 tests.
  • Lee
    You were on the right track at the start of "Solution 2". The solution to this problem is obviously an application of the binsearch or binary search algorithim. You divide each remaining half of the floors and seach in the middle of the remaining segment of floors. As an example, if the ball breaks at the 50th floor, you go to the 25th floor for the next trial. If it doesn't break, you go to the 75th floor. The worst-case solution is seven bowling ball drops.
  • Lee,

    That's not true. What happens if the bad floor is the 10th floor? Once the ball breaks on the 25th floor you're done.
  • Jim Dunlop
    I'm not an engineer or a mathematician, but I am a logical sort of person with some kind of college science degree -- I've forgotten what it's in because I've never worked in the industry.

    Anyway, that aside, the problem is fundamentally flawed and I'd refuse to answer the question on those grounds (and obviously not get the job). At any rate, I like to think out of the box, so here's some out-of-the box considerations for this problem.

    The problem must first be re-defined to make it into a legitimate problem. Why? Any time you drop the bowling ball from any floor, you are subjecting it to forces that have the potential of breaking the ball. Now, even though a single drop from, say, the 10th floor may not break the ball, it may cause certain internal stress on the ball (or micro-fractures) that are not visible to the naked eye, which will cause the ball to break on the next drop above 10 (let's say 14 for the sake of argument). Thus, if you took a brand new, never-been-dropped ball and let it go from 14, not having suffered previous trauma, may stay intact, thus skewing your results.

    In order for this problem to become valid, you go over to company stores, and social-engineer them into requisitioning a box of bowling balls to be FedExed to you. Then you can start with a baseline of 50 floors, examine the results, and whether the ball breaks or not, add or subtract floors accordingly, but ensuring to drop a fresh ball each time. If you were to multiply or divide by a factor of 2 (or so): 50; (25 is not further divisible by 2 so let's just go ahead and descend one more floor)... 24; 12; 6; 3; 2; 1, your worst case scenario would look like this:
    (B=break; I=intact).
    50(B); 24(I); 36(B); 30(I); 33(B); 32(B); 31(B).

    If, however you are an unlucky bugger and the breaking point just happens to be 49, you might get this:

    50(B); 24(I); 36(I); 43(I); 46(I); 48(I); 49(B).

    Either way, the answer will be 7.

    Thus, make sure your purchasing department orders 25 bowling balls. That way you can run the experiment 3 times for consistency and to get accurate numbers. This will use 21 of the 25 balls. Then, you can take the remaining 4 balls, one for yourself, and 3 for the guys down in purchasing so you can take them out bowling as a "thank you" when all the BS is done!
  • Hotball
    This problem is recursive in nature. Basically, if you drop a ball at floor k, and it breaks, then you reduce the problem to one less ball with floor k -1. On the other hand, if it does not break, the problem becomes the same number of balls but with floor n - k.

    So, basically this problem can be solved with dynamic programming, by optimizing this:

    F(m, n) = 1 + max(F(m-1, k-1), F(m, n-k)) for k = 1.. n

    Running this on F(2, 100) can show that 14 is indeed the optimal solution. This should be able to changed to optimize for the average case, not the worst case.

    What's interesting is that (if my program is correct) it only takes 5 balls to achieve 7 steps (which is the best possible number of steps, since 2^6 < 100 and 2^7 > 100).
  • bob
    anyone take into account the acceleration of the ball.

    The speed of the ball is the key to when it breaks, and it goes as sqrt(h).
    So one should take that into account when sampling (i.e. sample not every S floors,
    but make it a uniform stride in impact velocity).

    from a physics point of view, questions are not asked to see the result, but
    how one thinks about things. Including discussions of important factors
    like:

    climbing up stairs, terminal velocity, the quick solution, the optimal solution,
    accumulated wear on the ball, insuring zero initial velocity, using non-integer floors
    by allowing a small initial downward velocity, or tossing the ball up halfway between floors,
    repeatability of the experiment, are the balls identical, why aren't the windows locked, measuring
    the temperature while doing the experiment, effect of Coriolis force on the ball, etc
  • ohh Math .. I think its so much puzzling Question
  • David B
    Well, the biggest problem I have with the entire problem is that you're missing a very pressing point. You only have two balls. If you drop even one ball one floor, you're fracturing the structure of the ball, and as such, weakening it. My biggest concern wouldn't be how many tries it takes, but to test the resilience of the ball and find the maximum height at which you could drop it and have it still maintain its integrity, then convert that to 'floors high' - Great question though!
  • Jackass
    Who cares.
  • Not you, clearly.
blog comments powered by Disqus