Optimizing an algorithm that's quadratic by design | Dark Hacker News