News for hackers. Stuff that matters.
Re:Is there an algorithm as beautiful as a poem? by ajuc on Sunday June 16, 2024 @04:04AM (#40695482)
Algorithms can certainly be elegant. A greedy algorithm with a lot of special cases added to force it to work feels yucky. A simple algorithm that does the minimal amount of work to get the job done and handles all the special cases without case-specific code feels good. Like a well-crafted, reliable tool. It might not be beauty yet, but it's close.

What makes it beautifull in my mind is the same thing that makes some poems beautifull - the fact that it seems simpler than the problem it solves, and yet it solves it well. If it evokes that surprising feeling of "That's it? That's enough?" - then it's beautifull, like a poem which expresses complex feeling in a few short verses.

For me Floyd-Warshall is one example.

There are no comments on this comment yet.