3 ms·
Many problems have tricky, performant solutions and simple, slow solutions. Comparing to a simple reference implementation is a very good way to test. For some
by adrianN 4y ago
Many problems have tricky, performant solutions and simple, slow solutions. Comparing to a simple reference implementation is a very good way to test.
For some problems it is much easier to check that the result is correct than to find the result (that's what P and NP are about for example). Sorting is one of these problems. You can check that one list is a permutation of another list in linear time. Comparing against a library implementation of sorting is just simpler in many languages.