|
Project Euler Solutions
|
All problems are solved in type-hinted python3
All files share a common prefix with their problem number. Several of the problems also have code leveraged as if they were a library. That list is (approximately):
As a style note, to preserve Doxygen namespacing I have imported whole modules rather than individual pieces of modules, as would normally be my preference. Not doing this caused problems with Doxygen's namespace and call graph features.
There are three main recipes in this Makefile
This recipe installs all the required and test dependencies. See the Dependencies section for more info
This recipe runs tests in a single thread and performs benchmarks and style checks on them.
This recipe runs tests in multiple threads, using however many are specified by the number after the _. For example, test_3 would spawn three python processes. Because benchmark disables itself when running in children processes, benchmark info is not available with this recipe.
There is a single test for the prime number infrastructure. It has three components:
For each problem it will check the answer against a known dictionary. If the problem is not in the "known slow" category (meaning that I generate the correct answer with a poor solution), it will run it as many times as the benchmark plugin wants. Otherwise it is run exactly once.
A test fails if it gets the wrong answer or if it takes more than 1 minute.
I try to keep the dependencies of this project as small as possible, except for test plugins. At the moment there are only two non-test dependencies:
This serialization library encodes things in the MessagePack format. The reason it is not only for testing is that it allows me to read from a cache of prime numbers stored on disk. This is not required, and if you remove it (and the import) things would still run correctly.
This library provides a collection of sorted containers. At the time of writing this, the only one I use is SortedSet() for the prime number generator. If I were willing to remove the prime number cache this would not be needed. I could also implement my own if need be.
If this variable is defined to something other than 0 or an empty string, the test suite will skip any tests which are not directly related to Project Euler problems. This value will default to the same value as ONLY_SLOW.
If this variable is defined to something other than 0 or an empty string, problems in the known_slow group will not be tested. This variable defaults to True on Termux systems. If both NO_SLOW and ONLY_SLOW are truthy, they will be ignored and a warning will be issued.
If this variable is defined to something other than 0 or an empty string, only problems in the known_slow group will be tested. If both NO_SLOW and ONLY_SLOW are truthy, they will be ignored and a warning will be issued.
1.8.11