Re: Puzzle challenge:
- Posted by Patrick Barnes <mrtrick at gmail.com> Aug 10, 2004
- 485 views
> > One. > > Drop it from the ground floor and it breaks, that's the top floor from which > > the > > orbs will survive (worst case). Alright, from an algorithmic point of view, what's the most number of times you'll have to drop something to determine the top survivable floor. :oP No more loopholes. The balls are resilient, and aren't weakened by each drop. Either they break, or they are fine. Um, any other loopholes I'll close too. So no thinking outside the box! Unfortunately the pure binary search won't work, because if you guess 50 first, and it's under, you lose your first ball (it breaks), and if you guess 25 second, and it's under, you lose your second ball... and you have no more to test with... It can be done in 19 tries like this (worst case): With first ball: 10 20 30 40 50 60 70 80 90 100 *break first ball* With second ball: 91 92 93 94 95 96 97 98 99 The second ball will break somewhere between 91 and 99, and you'll know the top floor. If the ball breaks at 18, then it's: 1st: 10 20 2nd:11 12 13 14 15 16 17 18 , the above is the worst case. So, 19 tries. I can do it in 14 though....14 or less tries, no matter what floor it breaks on... (Guess how) Haven't figured out a general case algorithm yet though.... -- MrTrick