The elegance of a mathematical proof often mirrors the efficiency of the algorithm it describes.