Improved standalone code for the Archimedes cattle problem.