On Feb 6, 4:54 pm, "John Machin" <[EMAIL PROTECTED]> wrote:
> Recursive? Bzzzt!

I woudl be happy to hear your alternative, which doesn't depend on
language specific tricks. Thus far, all you have suggested is using an
alternative form of the division function, which I would consider to
be outside the spirit of the question (though I have been wrong many
times before).

> Might it not be better to halve the interval at each iteration instead
> of calling a random number function? mid = (lo + hi) >> 1 looks
> permitted and cheap to me. Also you don't run the risk of it taking a
> very high number of iterations to get a result.

I had considered this, but to halve, you need to divide by 2. Using
random, while potentially increasing the number of iterations, removes
the dependency of language tricks and division.

> Did you notice the important word *efficiently* in line 1 of the spec?
> Even after ripping out recursion and random numbers, your proposed
> solution is still way off the pace.

Again, I look forward to reading your solution.

Respectfully, G.

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to