Thread: Pop quiz!
View Single Post
  #76  
Old 08-23-2004, 06:05 PM
NAHTMMM's Avatar
NAHTMMM NAHTMMM is offline
Noodles And Hot Tofu! MMM
Member
 
Join Date: Mar 2003
Location: St Louis, MO, USA, . . .
Posts: 2,961
Send a message via Yahoo to NAHTMMM
Default

I'm still not particularly happy with the (Mathematica) function I came up with...

Code:
ballfall[maxfloors_] := 
        Do[For[i = 0; cmax = IntegerPart[maxfloors];
               cmin = 1, cmax - cmin > 0, 
               i += 1, temp = Ceiling[(cmax + cmin)/2]; cmin = temp];
           Return[i], {1}]
^Highlight that code if you can't read it because of the colors


Ideally that would be a rounding-down function, not a ceiling function, but IntegerPart leads to an infinite loop of evil DOOM! when cmin is one less than cmax ... Still, the only mistakes should be that the smallest number of floors for which n trials are required might seem to require only n - 1 trials.


Here's a plot for up through 100 and a bit...
__________________
My 5MV webpages My novel fivers list

Yup

“There must have been a point in early human history when it was actually advantageous to, when confronted with a difficult task, drop it altogether and go do something more fun, because I do that way too often for it to be anything but instinct.” -- Isto Combs
Reply With Quote