Back to General discussions forum
I'm trying to solve task 34, binary search, and I've come up with the algorithm in both Python and Rust, but I can't seem to be able to get the precision required.
In the Python's algorithm case, I can do 5 decimals before the program gets stuck, and in Rust, I managed to reach 6.
Any ideas that could help me optimize things in general? I'd post code, but I don't want to spoil my solution to others.
I would print intermediate values as they converge. I suspect you might have an issue with either a stopping criterion or shrinking the interval. Generally speaking, for binary search convergence is quick (i.e., the speed of the algorith should be linear with the number of the digits of precision).
Okay, in the end the issue was mine, as I had messed up the algorithm. Thanks for the help, though!
Hello! What do you mean by stuck? Also, is the version here your most up-to-date version?