Optimisations and corrections

The first 25 problems now run collectively in under 30 seconds. All give correct answers. Most run in under 1 second, and the longest execution time is 6.6. Using Python v3.