Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

>I start most of my algorithms with while (true)

That's gonna hurt

>When you’ve got a while (true)* loop that searches a tree, it’s gonna throw you an infinite loop every now and then. Fortunately, the more times this happens the better you’ll get at lightweight debugging strategies, and the more familiar you’ll become with the algorithm and the data structures

I like your style, kid.



Reminds me of another style:

"Just do it, hack! I approach code like games, rush deep into room, trigger all NPCs, die, after respawn I know where NPCs are." --@bkaradzic


I always add a counter to the infinite loops to break out of them incase of unexpectedly high number of iterations


Error out or something? Otherwise it would seem the program is in a weird state.


Error, or do the sensible “no results found” for example in the tree search.


... and then what?


Like the article said. Break out into a debugger and figure out why it got stuck.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: