Earlier quoted context omitted.
`git bisect` is an indispensible git trick. You give it commit where you know the bug exists, and one where you know it doesn't and it'll use binary search to help you find where the bug came from. It's absolutely wonderful.
I always struggle to see why people bang on about git bisect. You need tests to make it work. If you have tests, why aren't you running them continuously? If you're running them continuously, why do you need git bisect?
Ask HN: What's your favorite elegant/beautiful algorithm?
411–420 of 507 posts
Re: Ask HN: What's your favorite elegant/beautiful algorithm?
#412Earlier quoted context omitted.
`git bisect` is an indispensible git trick. You give it commit where you know the bug exists, and one where you know it doesn't and it'll use binary search to help you find where the bug came from. It's absolutely wonderful.
I always struggle to see why people bang on about git bisect. You need tests to make it work. If you have tests, why aren't you running them continuously? If you're running them continuously, why do you need git bisect?
Re: Ask HN: What's your favorite elegant/beautiful algorithm?
#413Earlier quoted context omitted.
Any suggestions where I can read about the BitTorrent protocol?
I implemented a BitTorrent client as a sophomore in college, available here: https://github.com/war1025/Torrent It worked pretty well. Used it for several years until I started making real money and decided I could buy things rather than pirate them. I had only been coding for a year or two at that point, so it is probably filled with lots of odd choices, but it also isn't super optimized like I would guess the more…
Re: Ask HN: What's your favorite elegant/beautiful algorithm?
#414Earlier quoted context omitted.
Nice in theory, but in practice you wouldn't implement it like that, especially if the words can be longer than your machine integer allows. Sorting and comparing is more elegant than invoking a BigNum library, imho (and has smaller footprint). This shows that theoretical elegance != implementation elegance.
The title asked for beautiful/elegant algorithms, not efficient ones! :)
Re: Ask HN: What's your favorite elegant/beautiful algorithm?
#415Earlier quoted context omitted.
`git bisect` is an indispensible git trick. You give it commit where you know the bug exists, and one where you know it doesn't and it'll use binary search to help you find where the bug came from. It's absolutely wonderful.
I always struggle to see why people bang on about git bisect. You need tests to make it work. If you have tests, why aren't you running them continuously? If you're running them continuously, why do you need git bisect?
As for the rest of us mere mortals, we sometimes write code that has bugs without discovering those bugs right away. In a complex system, it might not be easy to observe an incorrect behavior and immediately deduce the root cause. "git bisect" allows you to retroactively track down the commit that introduced a behavior change, even if it was something you didn't originally think to test for.
Re: Ask HN: What's your favorite elegant/beautiful algorithm?
#416Wikipedia entry:
https://en.wikipedia.org/wiki/Rabin%E2%80%93Karp_algorithm
Implementation example (2 GB/s scan on modern 3GHz CPU):
https://github.com/faragon/libsrt/blob/master/src/saux/ssear...
Re: Ask HN: What's your favorite elegant/beautiful algorithm?
#417Re: Ask HN: What's your favorite elegant/beautiful algorithm?
#418Re: Ask HN: What's your favorite elegant/beautiful algorithm?
#419Re: Ask HN: What's your favorite elegant/beautiful algorithm?
#420not because it's super practical ( and there are other variations using other operators )
I like it because it is super simple and when I first encountered it early on in my learning, it was really not immediately obvious why it worked. It's probably been the simplest piece of code that's surprised me.