SCJP 1.6 ,SCWCD 5
Rohan kanade wrote:use binary search.
maybe it will take 2-3 iterations.
SCJP 1.6 ,SCWCD 5
Rohan kanade wrote:so what is the solution?
Mike Simmons wrote:Seems a little early to give up, isn't it?
I have a solution requiring 10 drops. I believe this is optimal for the problem as stated. But I'll give others a chance before I reveal more details.
Ryan McGuire wrote:Follow-up question: What if you had 3 identical breakable objects and an 80-story building?
Ryan McGuire wrote:How about N breakables and an M-story building? Even if you can't write the complete formula, how would you go about solving it?
Mike Simmons wrote:Hey - someone snuck a new question in after I read their last post. No fair!
Fortunately, it was essentially the same question I was thinking about...
Ryan McGuire wrote:Follow-up question: What if you had 3 identical breakable objects and an 80-story building?
8 drops. Or if you had 4 identical breakable objects, then 7 drops. Unfortunately, after this you no longer can reduce the number of drops by increasing the number of objects. You need 7 drops for any number of objects greater than 3, to solve an 80-story building.
Ryan McGuire wrote:How about N breakables and an M-story building? Even if you can't write the complete formula, how would you go about solving it?
Well, I don't have a single analytic formula for that (yet), but I do have a fairly simple algorithm for making a table to solve it. I have a feeling further simplification is possible though, so I'll post more later.
Ryan McGuire wrote:
Don't get me started about those stupid light bulbs. |