Ask HN: What's your favorite elegant/beautiful algorithm? 8 years ago
By far Dekker's algorithm to ensure mutual-exclusion in concurrent programming: (https://en.wikipedia.org/wiki/Dekker%27s_algorithm)
Less than 10 lines of code to create a piece of art.