logoalt Hacker News

globular-toasttoday at 6:25 AM1 replyview on HN

I was curious so checked to see how I implemented it in 2010. I did indeed use a while loop with a conditional break for the "repeat this test if" part. It just seems like the obvious implementation in C, to be honest. The book Hacker's Delight implements it more literally as an implicit loop using goto, but I was taught not to use goto and probably followed that rule at the time.

I don't think I interpreted it as strictly a loop, though, because normally that's a bigger deal and not casually hidden in one step of an algorithm. Algorithm M, for example has the loop parts annotated as such and always "go back to step M3" etc. My copy also has a comment in step D3 saying the test eliminates all cases where the guess is two too large, to it's completely understandable to not interpret it as a loop IMO.


Replies