From 6334b615a493d5b706ae51cd926937f500aa1acb Mon Sep 17 00:00:00 2001 From: Olivia Appleton Date: Fri, 28 Jun 2024 18:16:04 -0500 Subject: [PATCH] Prep for building documentation Python is easy Next step is C, Then JavaScript, Then C# Hopefully I don't need to scrape comments and do it manually --- .../{pages.yml.pending => pages.yml} | 10 + .gitignore | 3 +- Makefile | 3 + README.md | 28 --- README.rst | 62 ++++++ c/README.md | 115 ---------- c/README.rst | 200 +++++++++++++++++ csharp/README.md | 51 ----- csharp/README.rst | 80 +++++++ docs/Makefile | 36 +++ docs/c.rst | 12 + docs/conf.py | 54 +++++ docs/csharp.rst | 12 + docs/index.rst | 29 +++ docs/javascript.rst | 12 + docs/python.rst | 83 +++++++ docs/python/p0001.rst | 8 + docs/python/p0002.rst | 8 + docs/python/p0003.rst | 8 + docs/python/p0004.rst | 8 + docs/python/p0005.rst | 8 + docs/python/p0006.rst | 8 + docs/python/p0007.rst | 8 + docs/python/p0008.rst | 8 + docs/python/p0009.rst | 8 + docs/python/p0010.rst | 8 + docs/python/p0011.rst | 8 + docs/python/p0012.rst | 8 + docs/python/p0013.rst | 8 + docs/python/p0014.rst | 8 + docs/python/p0015.rst | 8 + docs/python/p0016.rst | 8 + docs/python/p0017.rst | 8 + docs/python/p0018.rst | 8 + docs/python/p0019.rst | 8 + docs/python/p0020.rst | 8 + docs/python/p0021.rst | 8 + docs/python/p0022.rst | 8 + docs/python/p0023.rst | 8 + docs/python/p0024.rst | 8 + docs/python/p0025.rst | 8 + docs/python/p0027.rst | 8 + docs/python/p0029.rst | 8 + docs/python/p0030.rst | 8 + docs/python/p0031.rst | 8 + docs/python/p0032.rst | 8 + docs/python/p0033.rst | 8 + docs/python/p0034.rst | 8 + docs/python/p0035.rst | 8 + docs/python/p0036.rst | 8 + docs/python/p0037.rst | 8 + docs/python/p0038.rst | 8 + docs/python/p0039.rst | 8 + docs/python/p0040.rst | 8 + docs/python/p0041.rst | 8 + docs/python/p0042.rst | 8 + docs/python/p0043.rst | 8 + docs/python/p0044.rst | 8 + docs/python/p0045.rst | 8 + docs/python/p0046.rst | 8 + docs/python/p0047.rst | 8 + docs/python/p0048.rst | 8 + docs/python/p0049.rst | 8 + docs/python/p0050.rst | 8 + docs/python/p0052.rst | 8 + docs/python/p0053.rst | 8 + docs/python/p0055.rst | 8 + docs/python/p0056.rst | 8 + docs/python/p0057.rst | 8 + docs/python/p0059.rst | 8 + docs/python/p0067.rst | 8 + docs/python/p0069.rst | 8 + docs/python/p0071.rst | 8 + docs/python/p0073.rst | 8 + docs/python/p0074.rst | 8 + docs/python/p0076.rst | 8 + docs/python/p0077.rst | 8 + docs/python/p0087.rst | 8 + docs/python/p0092.rst | 8 + docs/python/p0097.rst | 8 + docs/python/p0118.rst | 8 + docs/python/p0123.rst | 8 + docs/python/p0134.rst | 8 + docs/python/p0145.rst | 8 + docs/python/p0187.rst | 8 + docs/python/p0206.rst | 8 + docs/requirements.txt | 3 + docs/usage.rst | 11 + javascript/README.md | 40 ---- javascript/README.rst | 64 ++++++ python/README.md | 153 ------------- python/README.rst | 209 ++++++++++++++++++ python/p0012.py | 2 + python/p0018.py | 42 ++-- python/p0027.py | 10 +- 95 files changed, 1472 insertions(+), 412 deletions(-) rename .github/workflows/{pages.yml.pending => pages.yml} (74%) delete mode 100644 README.md create mode 100644 README.rst delete mode 100644 c/README.md create mode 100644 c/README.rst delete mode 100644 csharp/README.md create mode 100644 csharp/README.rst create mode 100644 docs/Makefile create mode 100644 docs/c.rst create mode 100644 docs/conf.py create mode 100644 docs/csharp.rst create mode 100644 docs/index.rst create mode 100644 docs/javascript.rst create mode 100644 docs/python.rst create mode 100644 docs/python/p0001.rst create mode 100644 docs/python/p0002.rst create mode 100644 docs/python/p0003.rst create mode 100644 docs/python/p0004.rst create mode 100644 docs/python/p0005.rst create mode 100644 docs/python/p0006.rst create mode 100644 docs/python/p0007.rst create mode 100644 docs/python/p0008.rst create mode 100644 docs/python/p0009.rst create mode 100644 docs/python/p0010.rst create mode 100644 docs/python/p0011.rst create mode 100644 docs/python/p0012.rst create mode 100644 docs/python/p0013.rst create mode 100644 docs/python/p0014.rst create mode 100644 docs/python/p0015.rst create mode 100644 docs/python/p0016.rst create mode 100644 docs/python/p0017.rst create mode 100644 docs/python/p0018.rst create mode 100644 docs/python/p0019.rst create mode 100644 docs/python/p0020.rst create mode 100644 docs/python/p0021.rst create mode 100644 docs/python/p0022.rst create mode 100644 docs/python/p0023.rst create mode 100644 docs/python/p0024.rst create mode 100644 docs/python/p0025.rst create mode 100644 docs/python/p0027.rst create mode 100644 docs/python/p0029.rst create mode 100644 docs/python/p0030.rst create mode 100644 docs/python/p0031.rst create mode 100644 docs/python/p0032.rst create mode 100644 docs/python/p0033.rst create mode 100644 docs/python/p0034.rst create mode 100644 docs/python/p0035.rst create mode 100644 docs/python/p0036.rst create mode 100644 docs/python/p0037.rst create mode 100644 docs/python/p0038.rst create mode 100644 docs/python/p0039.rst create mode 100644 docs/python/p0040.rst create mode 100644 docs/python/p0041.rst create mode 100644 docs/python/p0042.rst create mode 100644 docs/python/p0043.rst create mode 100644 docs/python/p0044.rst create mode 100644 docs/python/p0045.rst create mode 100644 docs/python/p0046.rst create mode 100644 docs/python/p0047.rst create mode 100644 docs/python/p0048.rst create mode 100644 docs/python/p0049.rst create mode 100644 docs/python/p0050.rst create mode 100644 docs/python/p0052.rst create mode 100644 docs/python/p0053.rst create mode 100644 docs/python/p0055.rst create mode 100644 docs/python/p0056.rst create mode 100644 docs/python/p0057.rst create mode 100644 docs/python/p0059.rst create mode 100644 docs/python/p0067.rst create mode 100644 docs/python/p0069.rst create mode 100644 docs/python/p0071.rst create mode 100644 docs/python/p0073.rst create mode 100644 docs/python/p0074.rst create mode 100644 docs/python/p0076.rst create mode 100644 docs/python/p0077.rst create mode 100644 docs/python/p0087.rst create mode 100644 docs/python/p0092.rst create mode 100644 docs/python/p0097.rst create mode 100644 docs/python/p0118.rst create mode 100644 docs/python/p0123.rst create mode 100644 docs/python/p0134.rst create mode 100644 docs/python/p0145.rst create mode 100644 docs/python/p0187.rst create mode 100644 docs/python/p0206.rst create mode 100644 docs/requirements.txt create mode 100644 docs/usage.rst delete mode 100644 javascript/README.md create mode 100644 javascript/README.rst delete mode 100644 python/README.md create mode 100644 python/README.rst diff --git a/.github/workflows/pages.yml.pending b/.github/workflows/pages.yml similarity index 74% rename from .github/workflows/pages.yml.pending rename to .github/workflows/pages.yml index d723b9de..568b1fbb 100644 --- a/.github/workflows/pages.yml.pending +++ b/.github/workflows/pages.yml @@ -11,6 +11,16 @@ jobs: with: submodules: true + - name: Use Python 3.12 + uses: actions/setup-python@v5 + with: + python-version: 3.12 + cache: 'pip' + cache-dependency-path: | + python/requirements.txt + c/requirements.txt + docs/requirements.txt + - uses: ammaraskar/sphinx-action@master with: docs-folder: "docs/" diff --git a/.gitignore b/.gitignore index 5862b85a..fe0b1aa9 100644 --- a/.gitignore +++ b/.gitignore @@ -12,4 +12,5 @@ venv/** **.pdb csharp/*/obj csharp/*/bin -**/TestResults \ No newline at end of file +**/TestResults +docs/_build \ No newline at end of file diff --git a/Makefile b/Makefile index f7ea1dd3..31c52d1b 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,9 @@ PY?=python3 PROXY?= +html: + cd docs && $(make) $(MFLAGS) + py%: cd python && $(MAKE) $* $(MFLAGS) diff --git a/README.md b/README.md deleted file mode 100644 index 568bf3a9..00000000 --- a/README.md +++ /dev/null @@ -1,28 +0,0 @@ -# LivInTheLookingGlass's Project Euler solutions - -| Language | Version | Solved | Status | -|:---------|:--------|:-------|:-------| -| C | C11+
gcc, pcc, tcc
clang, msvc | 17 | [![C](https://github.com/LivInTheLookingGlass/Euler/actions/workflows/c.yml/badge.svg)](https://github.com/LivInTheLookingGlass/Euler/actions/workflows/c.yml) | -| C# | 5+ | 1 | [![C#](https://github.com/LivInTheLookingGlass/Euler/actions/workflows/csharp.yml/badge.svg)](https://github.com/LivInTheLookingGlass/Euler/actions/workflows/csharp.yml) | -| JavaScript | Node 12+ | 2 | [![JavaScript](https://github.com/LivInTheLookingGlass/Euler/actions/workflows/javascript.yml/badge.svg)](https://github.com/LivInTheLookingGlass/Euler/actions/workflows/javascript.yml) | -| Python | CPython 3.6+
Pypy 3.8+
GraalPy 23.1+ | 70 | [![Python](https://github.com/LivInTheLookingGlass/Euler/actions/workflows/python.yml/badge.svg)](https://github.com/LivInTheLookingGlass/Euler/actions/workflows/python.yml) | -| CodeQL Scanning ||| [![CodeQL](https://github.com/LivInTheLookingGlass/Euler/actions/workflows/c.yml/badge.svg)](https://github.com/LivInTheLookingGlass/Euler/actions/workflows/codeql.yml) | - -This is the repository I keep for prospective employers to look at project Euler code that I have written. - -This is useful because it has defined problems and answers such that you can compare answers with other people. - -All solutions are tested against multiple operating systems and language/compiler versions. For more information, see `.github/workflows/` - -## This is NOT meant to help others on Project Euler problems - -## If you are working on Project Euler problems, DO NOT use this as a source - -The repo is divided into sections for each language. The top-level Makefile will direct recipes using prefixes - -- `make c*` will go to the c Makefile -- `make cs*` will go to the csharp Makefile -- `make py*` will go to the python Makefile -- `make js*` will go to the javascript Makefile - -For more information, please see the README documents in each section. diff --git a/README.rst b/README.rst new file mode 100644 index 00000000..1ae50162 --- /dev/null +++ b/README.rst @@ -0,0 +1,62 @@ +LivInTheLookingGlass’s Project Euler solutions +============================================== + +.. |C| image:: https://github.com/LivInTheLookingGlass/Euler/actions/workflows/c.yml/badge.svg + :target: https://github.com/LivInTheLookingGlass/Euler/actions/workflows/c.yml +.. |C#| image:: https://github.com/LivInTheLookingGlass/Euler/actions/workflows/csharp.yml/badge.svg + :target: https://github.com/LivInTheLookingGlass/Euler/actions/workflows/csharp.yml +.. |JavaScript| image:: https://github.com/LivInTheLookingGlass/Euler/actions/workflows/javascript.yml/badge.svg + :target: https://github.com/LivInTheLookingGlass/Euler/actions/workflows/javascript.yml +.. |Python| image:: https://github.com/LivInTheLookingGlass/Euler/actions/workflows/python.yml/badge.svg + :target: https://github.com/LivInTheLookingGlass/Euler/actions/workflows/python.yml +.. |CodeQL| image:: https://github.com/LivInTheLookingGlass/Euler/actions/workflows/c.yml/badge.svg + :target: https://github.com/LivInTheLookingGlass/Euler/actions/workflows/codeql.yml +.. |br| raw:: html + +
+.. |total| replace:: 642 + ++------------+---------------------+--------------+--------------+ +| Language | Version | Solved | Status | ++============+=====================+==============+==============+ +| C | C11+ in: |br| | 17 / |total| | |C| | +| | ``gcc``, ``pcc``, | | | +| | ``tcc``, |br| | | | +| | ``clang``, ``msvc`` | | | ++------------+---------------------+--------------+--------------+ +| C# | .NET 5+ | 1 / |total| | |C#| | ++------------+---------------------+--------------+--------------+ +| JavaScript | Node 12+ | 2 / |total| | |JavaScript| | ++------------+---------------------+--------------+--------------+ +| Python | CPython 3.6+ |br| | 70 / |total| | |Python| | +| | Pypy 3.8+ |br| | | | +| | GraalPy 23.1+ | | | ++------------+---------------------+--------------+--------------+ +| CodeQL Scanning | |CodeQL| | ++-------------------------------------------------+--------------+ + +This is the repository I keep for prospective employers to look at +project Euler code that I have written. + +This is useful because it has defined problems and answers such that you +can compare answers with other people. + +All solutions are tested against multiple operating systems and +language/compiler versions. For more information, see +``.github/workflows/`` + +This is NOT meant to help others on Project Euler problems +---------------------------------------------------------- + +If you are working on Project Euler problems, DO NOT use this as a source +------------------------------------------------------------------------- + +The repo is divided into sections for each language. The top-level +Makefile will direct recipes using prefixes + +- ``make c*`` will go to the c Makefile +- ``make cs*`` will go to the csharp Makefile +- ``make py*`` will go to the python Makefile +- ``make js*`` will go to the javascript Makefile + +For more information, please see the README documents in each section. \ No newline at end of file diff --git a/c/README.md b/c/README.md deleted file mode 100644 index de40c1b9..00000000 --- a/c/README.md +++ /dev/null @@ -1,115 +0,0 @@ -# C Section - -[![C Check](https://github.com/LivInTheLookingGlass/Euler/actions/workflows/c.yml/badge.svg)](https://github.com/LivInTheLookingGlass/Euler/actions/workflows/c.yml) - -All problems are solved in C11, though most if not all of it is C99-compatible. It is tested on clang, gcc, and cl (the Visual Studios compiler). - -## Organization - -All C files share a common prefix with their problem number. All shared functions are moved to header files in the include subfolder - -## Makefile - -There are four main recipes in this Makefile - -### dependencies - -This recipe installs all the required and test dependencies. See the Dependencies section for more info - -### test - -This recipe runs tests in a single thread and performs benchmarks on each. This test infrastructure is recycled from the python section. - -### test_* - -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. - -### native - -This recipe builds a test executable using the Unity test framework. It recycles no Python infrastructure, but consequently cannot test some features like compiler macros and deterministic building. - -## Tests - -### Compiler Detection Macros - -There are a set of macros which detect which compiler is being used. These macros are mostly used to route around issues with particular compilers. For instance, PCC does not allow me to include `` or `` on the systems I've tested it on, so I need to route around that. This test checks that those macros are correct. - -### Prime Infrastructure Test - -This test checks five things: - -1. It checks `is_prime()` for numbers up to `MAX_PRIME`, where that is defined in the test -2. It checks that `is_composite()` returns truthy values on composites in that range, and falsey values on primes -3. It checks that `is_composite()` returns the smallest prime factor on composite numbers -4. It checks that the prime numbers are generated in the correct order -5. It checks that all these operations are completed in less than 200ns * `MAX_PRIME` - -### Generic Problems - -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. - -## Dependencies - -I try to keep the dependencies of this project as small as possible, except for test plugins. At the moment there are no non-test dependencies for this section. - -Note that there are optional test that leverage the Python infrastructure. If you want these tests to work you need to go to the python folder and run `make dependencies` or define the [`NO_OPTIONAL_TESTS`](#no-slow-tests) environment variable. - -## Environment Variables - -### COMPILER_OVERRIDE - -If this variable is defined, it should contain a comma-separated list of the compilers you would like to test from the following list (case insensitive): - -* aocc (AMD Optimized C Compiler) -* cl (Visual Studios compiler) -* clang -* gcc -* icc (Intel C Compiler) -* pcc (Portable C Compiler) -* tcc (Tiny C Compiler) - -If this variable is not defined, compilers will be auto-detected using `which()`. - -### AOCC_OVERRIDE - -If this variable is defined, it should hold a string representing the AMD compiler binary you would like to use. One case you may want this in is to test both the AMD compiler and traditional clang by renaming the AMD compiler's executable. - -### GCC_OVERRIDE - -If this variable is defined, it should hold a string representing the `gcc` binary you would like to use. One case you may want this in is on OSX or Termux, where `gcc` is often remapped to `clang`. - -### NO_OPTIONAL_TESTS - -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`](#only-slow). - -### NO_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`](#no-slow) and [`ONLY_SLOW`](#only-slow) are truthy, they will be ignored and a warning will be issued. - -### ONLY_SLOW - -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`](#no-slow) and [`ONLY_SLOW`](#only-slow) are truthy, they will be ignored and a warning will be issued. - -## Problems Solved - -- [x] [1](./p0001.c) -- [x] [2](./p0002.c) -- [x] [3](./p0003.c) -- [x] [4](./p0004.c) -- [x] [5](./p0005.c) -- [x] [6](./p0006.c) -- [x] [7](./p0007.c) -- [x] [8](./p0008.c) -- [x] [9](./p0009.c) -- [x] [10](./p0010.c) -- [x] [11](./p0011.c) -- [ ] [12](./p0012.c) -- [x] [13](./p0013.c) -- [x] [14](./p0014.c) -- [x] [15](./p0015.c) -- [x] [16](./p0016.c) -- [x] [34](./p0034.c) -- [x] [76](./p0076.c) - diff --git a/c/README.rst b/c/README.rst new file mode 100644 index 00000000..62ee274d --- /dev/null +++ b/c/README.rst @@ -0,0 +1,200 @@ +C Section +========= + +.. |C Check| image:: https://github.com/LivInTheLookingGlass/Euler/actions/workflows/c.yml/badge.svg + :target: https://github.com/LivInTheLookingGlass/Euler/actions/workflows/c.yml + +|C Check| + +All problems are solved in C11, though most if not all of it is +C99-compatible. It is tested on clang, gcc, pcc, tcc, and msvc (the Visual Studios +compiler). + +Organization +------------ + +All C files share a common prefix with their problem number. All shared +functions are moved to header files in the include subfolder + +Makefile +-------- + +There are four main recipes in this Makefile + +dependencies +~~~~~~~~~~~~ + +This recipe installs all the required and test dependencies. See the +Dependencies section for more info + +test +~~~~ + +This recipe runs tests in a single thread and performs benchmarks on +each. This test infrastructure is recycled from the python section. + +test\_\* +~~~~~~~~ + +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. + +native +~~~~~~ + +This recipe builds a test executable using the Unity test framework. It +recycles no Python infrastructure, but consequently cannot test some +features like compiler macros and deterministic building. + +Tests +----- + +Compiler Detection Macros +~~~~~~~~~~~~~~~~~~~~~~~~~ + +There are a set of macros which detect which compiler is being used. +These macros are mostly used to route around issues with particular +compilers. For instance, PCC does not allow me to include ```` +or ```` on the systems I've tested it on, so I need to route +around that. This test checks that those macros are correct. + +Prime Infrastructure Test +~~~~~~~~~~~~~~~~~~~~~~~~~ + +This test checks five things: + +1. It checks ``is_prime()`` for numbers up to ``MAX_PRIME``, where that + is defined in the test +2. It checks that ``is_composite()`` returns truthy values on composites + in that range, and falsey values on primes +3. It checks that ``is_composite()`` returns the smallest prime factor + on composite numbers +4. It checks that the prime numbers are generated in the correct order +5. It checks that all these operations are completed in less than 200ns + \* ``MAX_PRIME`` + +Generic Problems +~~~~~~~~~~~~~~~~ + +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. + +Dependencies +------------ + +I try to keep the dependencies of this project as small as possible, +except for test plugins. At the moment there are no non-test +dependencies for this section. + +Note that there are optional test that leverage the Python +infrastructure. If you want these tests to work you need to go to the +python folder and run ``make dependencies`` or define the +`NO_OPTIONAL_TESTS <#no-slow-tests>`__ environment variable. + +Environment Variables +--------------------- + +COMPILER_OVERRIDE +~~~~~~~~~~~~~~~~~ + +If this variable is defined, it should contain a comma-separated list of +the compilers you would like to test from the following list (case +insensitive): + +- aocc (AMD Optimized C Compiler) +- cl (Visual Studios compiler) +- clang +- gcc +- icc (Intel C Compiler) +- pcc (Portable C Compiler) +- tcc (Tiny C Compiler) + +If this variable is not defined, compilers will be auto-detected using +``which()``. + +AOCC_OVERRIDE +~~~~~~~~~~~~~ + +If this variable is defined, it should hold a string representing the +AMD compiler binary you would like to use. One case you may want this in +is to test both the AMD compiler and traditional clang by renaming the +AMD compiler's executable. + +GCC_OVERRIDE +~~~~~~~~~~~~ + +If this variable is defined, it should hold a string representing the +``gcc`` binary you would like to use. One case you may want this in is +on OSX or Termux, where ``gcc`` is often remapped to ``clang``. + +NO_OPTIONAL_TESTS +~~~~~~~~~~~~~~~~~ + +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 <#only-slow>`__. + +NO_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 <#no-slow>`__ and `ONLY_SLOW <#only-slow>`__ are +truthy, they will be ignored and a warning will be issued. + +ONLY_SLOW +~~~~~~~~~ + +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 <#no-slow>`__ and `ONLY_SLOW <#only-slow>`__ are +truthy, they will be ignored and a warning will be issued. + +Problems Solved +--------------- + +- ☒ `1 <./p0001.c>`__ + +- ☒ `2 <./p0002.c>`__ + +- ☒ `3 <./p0003.c>`__ + +- ☒ `4 <./p0004.c>`__ + +- ☒ `5 <./p0005.c>`__ + +- ☒ `6 <./p0006.c>`__ + +- ☒ `7 <./p0007.c>`__ + +- ☒ `8 <./p0008.c>`__ + +- ☒ `9 <./p0009.c>`__ + +- ☒ `10 <./p0010.c>`__ + +- ☒ `11 <./p0011.c>`__ + +- ☐ `12 <./p0012.c>`__ + +- ☒ `13 <./p0013.c>`__ + +- ☒ `14 <./p0014.c>`__ + +- ☒ `15 <./p0015.c>`__ + +- ☒ `16 <./p0016.c>`__ + +- ☒ `34 <./p0034.c>`__ + +- ☒ `76 <./p0076.c>`__ diff --git a/csharp/README.md b/csharp/README.md deleted file mode 100644 index 315cac51..00000000 --- a/csharp/README.md +++ /dev/null @@ -1,51 +0,0 @@ -# C# Section - -[![C# Check](https://github.com/LivInTheLookingGlass/Euler/actions/workflows/csharp.yml/badge.svg)](https://github.com/LivInTheLookingGlass/Euler/actions/workflows/csharp.yml) - -All problems are solved in .NET 6, though an effort is made to support other versions. - -## Organization - -All C# files share a common prefix with their problem number. All shared functions are defined in the include folder. - -## Makefile - -There are three main recipes in this Makefile - -### dependencies - -This recipe installs all the required and test dependencies. See the Dependencies section for more info - -### test - -This recipe runs tests in multiple threads - -### lint - -This recipe runs `dotnet`s builtin linter with the `--verify-no-changes` flag - -## Tests - -### Prime Infrastructure Test - -This test checks five things: - -1. It checks `is_prime()` for numbers up to `MAX_PRIME`, where that is defined in the test -2. It checks that `is_composite()` returns truthy values on composites in that range, and falsey values on primes -3. It checks that `is_composite()` returns the smallest prime factor on composite numbers -4. It checks that the prime numbers are generated in the correct order -5. It checks that all these operations are completed in less than 200ns * `MAX_PRIME` - -### Generic Problems - -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 always be run. Otherwise it tries to detect the `NO_SLOW` environment variable and dynamically skip them. - -A test fails if it gets the wrong answer or if it takes more than 1 minute. - -## Dependencies - -I try to keep the dependencies of this project as small as possible, except for test plugins. At the moment there are no non-test dependencies for this section. - -## Problems Solved - -- [x] [1](./p0001.cs) diff --git a/csharp/README.rst b/csharp/README.rst new file mode 100644 index 00000000..65816dd0 --- /dev/null +++ b/csharp/README.rst @@ -0,0 +1,80 @@ +C# Section +========== + +.. |C# Check| image:: https://github.com/LivInTheLookingGlass/Euler/actions/workflows/csharp.yml/badge.svg + :target: https://github.com/LivInTheLookingGlass/Euler/actions/workflows/csharp.yml + +|C# Check| + +All problems are solved in .NET 6, though an effort is made to support +other versions. + +Organization +------------ + +All C# files share a common prefix with their problem number. All shared +functions are defined in the include folder. + +Makefile +-------- + +There are three main recipes in this Makefile + +dependencies +~~~~~~~~~~~~ + +This recipe installs all the required and test dependencies. See the +Dependencies section for more info + +test +~~~~ + +This recipe runs tests in multiple threads + +lint +~~~~ + +This recipe runs ``dotnet``\ s builtin linter with the +``--verify-no-changes`` flag + +Tests +----- + +Prime Infrastructure Test +~~~~~~~~~~~~~~~~~~~~~~~~~ + +This test checks five things: + +1. It checks ``is_prime()`` for numbers up to ``MAX_PRIME``, where that + is defined in the test +2. It checks that ``is_composite()`` returns truthy values on composites + in that range, and falsey values on primes +3. It checks that ``is_composite()`` returns the smallest prime factor + on composite numbers +4. It checks that the prime numbers are generated in the correct order +5. It checks that all these operations are completed in less than 200ns + \* ``MAX_PRIME`` + +Generic Problems +~~~~~~~~~~~~~~~~ + +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 always be run. +Otherwise it tries to detect the ``NO_SLOW`` environment variable and +dynamically skip them. + +A test fails if it gets the wrong answer or if it takes more than 1 +minute. + +Dependencies +------------ + +I try to keep the dependencies of this project as small as possible, +except for test plugins. At the moment there are no non-test +dependencies for this section. + +Problems Solved +--------------- + +- ☒ `1 <./p0001.cs>`__ diff --git a/docs/Makefile b/docs/Makefile new file mode 100644 index 00000000..aa8967e6 --- /dev/null +++ b/docs/Makefile @@ -0,0 +1,36 @@ +# Minimal makefile for Sphinx documentation +# + +# You can set these variables from the command line, and also +# from the environment for the first two. +SPHINXOPTS ?= -j auto +SPHINXBUILD ?= sphinx-build +SOURCEDIR = . +BUILDDIR = _build +PY?=python3 +USER_FLAG?=--user +PIP?=$(PY) -m pip +ifneq ($(https_proxy), ) +PROXY_ARG=--proxy=$(https_proxy) +else +ifneq ($(http_proxy), ) +PROXY_ARG=--proxy=$(http_proxy) +else +PROXY_ARG= +endif +endif + +# Put it first so that "make" without argument is like "make help". +help: + @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) + +.PHONY: help Makefile + +dependencies: + $(PIP) install -r requirements.txt $(USER_FLAG) $(PROXY_ARG) + cd ../python && $(MAKE) dependencies $(MFLAGS) + +# Catch-all target: route all unknown targets to Sphinx using the new +# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). +%: Makefile dependencies + $(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) diff --git a/docs/c.rst b/docs/c.rst new file mode 100644 index 00000000..b0866e1b --- /dev/null +++ b/docs/c.rst @@ -0,0 +1,12 @@ +Euler C Implementation +====================== + +.. include:: ../c/README.rst + :start-line: 2 + :end-before: Problems Solved + +Problems Solved +~~~~~~~~~~~~~~~ + +.. toctree:: + :maxdepth: 1 diff --git a/docs/conf.py b/docs/conf.py new file mode 100644 index 00000000..23f7fef6 --- /dev/null +++ b/docs/conf.py @@ -0,0 +1,54 @@ +# Configuration file for the Sphinx documentation builder. +# +# For the full list of built-in configuration values, see the documentation: +# https://www.sphinx-doc.org/en/master/usage/configuration.html + +# -- Project information ----------------------------------------------------- +# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information + +import os +import sys +basedir = os.path.abspath(os.path.join(os.path.dirname(__file__), '..')) +sys.path.insert(0, basedir) +sys.path.insert(0, basedir + os.sep + 'python') + +project = 'Euler' +copyright = '2024, Olivia Appleton' +author = 'Olivia Appleton' + +# -- General configuration --------------------------------------------------- +# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration + +extensions = [ + 'sphinx.ext.autodoc', + 'sphinx.ext.autosectionlabel', + 'sphinx.ext.githubpages', + 'sphinx.ext.graphviz', + 'sphinx.ext.inheritance_diagram', + 'sphinx.ext.mathjax', + 'sphinx.ext.todo', + # 'sphinx-c-autodoc', + # 'breathe', + # 'javasphinx', + # 'sphinx-autodoc-typehints', + # 'sphinx-git', + # 'sphinx-pyreverse', + # 'sphinxcontrib-autojs', + # 'sphinx-csharp', +] + +templates_path = ['_templates'] +exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store'] + +language = 'english' + +# -- Options for HTML output ------------------------------------------------- +# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output + +html_theme = 'agogo' +html_static_path = ['_static'] + +# -- Options for todo extension ---------------------------------------------- +# https://www.sphinx-doc.org/en/master/usage/extensions/todo.html#configuration + +todo_include_todos = True diff --git a/docs/csharp.rst b/docs/csharp.rst new file mode 100644 index 00000000..28245eb9 --- /dev/null +++ b/docs/csharp.rst @@ -0,0 +1,12 @@ +Euler C# Implementation +======================= + +.. include:: ../csharp/README.rst + :start-line: 2 + :end-before: Problems Solved + +Problems Solved +~~~~~~~~~~~~~~~ + +.. toctree:: + :maxdepth: 1 diff --git a/docs/index.rst b/docs/index.rst new file mode 100644 index 00000000..4dc556f4 --- /dev/null +++ b/docs/index.rst @@ -0,0 +1,29 @@ +.. Euler documentation master file, created by + sphinx-quickstart on Fri Jun 28 11:07:39 2024. + You can adapt this file completely to your liking, but it should at least + contain the root `toctree` directive. + +Welcome to Euler's documentation! +================================= + +.. toctree:: + :maxdepth: 1 + + usage + c + csharp + javascript + python + +Indices and tables +================== + +* :ref:`genindex` +* :ref:`modindex` +* :ref:`search` + +.. Recent Changes +.. ============== + +.. .. git_changelog:: +.. :revisions: 16 \ No newline at end of file diff --git a/docs/javascript.rst b/docs/javascript.rst new file mode 100644 index 00000000..d1bc4f94 --- /dev/null +++ b/docs/javascript.rst @@ -0,0 +1,12 @@ +Euler JavaScript Implementation +=============================== + +.. include:: ../javascript/README.rst + :start-line: 2 + :end-before: Problems Solved + +Problems Solved +~~~~~~~~~~~~~~~ + +.. toctree:: + :maxdepth: 1 diff --git a/docs/python.rst b/docs/python.rst new file mode 100644 index 00000000..5fc3ef15 --- /dev/null +++ b/docs/python.rst @@ -0,0 +1,83 @@ +Euler Python Implementation +=========================== + +.. include:: ../python/README.rst + :start-line: 2 + :end-before: Problems Solved + +Problems Solved +~~~~~~~~~~~~~~~ + +.. toctree:: + :maxdepth: 1 + + python/p0001.rst + python/p0002.rst + python/p0003.rst + python/p0004.rst + python/p0005.rst + python/p0006.rst + python/p0007.rst + python/p0008.rst + python/p0009.rst + python/p0010.rst + python/p0011.rst + python/p0012.rst + python/p0013.rst + python/p0014.rst + python/p0015.rst + python/p0016.rst + python/p0017.rst + python/p0018.rst + python/p0019.rst + python/p0020.rst + python/p0021.rst + python/p0022.rst + python/p0023.rst + python/p0024.rst + python/p0025.rst + python/p0027.rst + python/p0029.rst + python/p0030.rst + python/p0031.rst + python/p0032.rst + python/p0033.rst + python/p0034.rst + python/p0035.rst + python/p0036.rst + python/p0037.rst + python/p0038.rst + python/p0039.rst + python/p0040.rst + python/p0041.rst + python/p0042.rst + python/p0043.rst + python/p0044.rst + python/p0045.rst + python/p0046.rst + python/p0047.rst + python/p0048.rst + python/p0049.rst + python/p0050.rst + python/p0052.rst + python/p0053.rst + python/p0055.rst + python/p0056.rst + python/p0057.rst + python/p0059.rst + python/p0067.rst + python/p0069.rst + python/p0071.rst + python/p0073.rst + python/p0074.rst + python/p0076.rst + python/p0077.rst + python/p0087.rst + python/p0092.rst + python/p0097.rst + python/p0118.rst + python/p0123.rst + python/p0134.rst + python/p0145.rst + python/p0187.rst + python/p0206.rst diff --git a/docs/python/p0001.rst b/docs/python/p0001.rst new file mode 100644 index 00000000..70bb251b --- /dev/null +++ b/docs/python/p0001.rst @@ -0,0 +1,8 @@ +Python Implementation of Problem 1 +================================== + +View source code `here on GitHub! `_ + +.. automodule:: python.p0001 + :members: + :undoc-members: diff --git a/docs/python/p0002.rst b/docs/python/p0002.rst new file mode 100644 index 00000000..1acbf695 --- /dev/null +++ b/docs/python/p0002.rst @@ -0,0 +1,8 @@ +Python Implementation of Problem 2 +================================== + +View source code `here on GitHub! `_ + +.. automodule:: python.p0002 + :members: + :undoc-members: diff --git a/docs/python/p0003.rst b/docs/python/p0003.rst new file mode 100644 index 00000000..abbdd996 --- /dev/null +++ b/docs/python/p0003.rst @@ -0,0 +1,8 @@ +Python Implementation of Problem 3 +================================== + +View source code `here on GitHub! `_ + +.. automodule:: python.p0003 + :members: + :undoc-members: diff --git a/docs/python/p0004.rst b/docs/python/p0004.rst new file mode 100644 index 00000000..5d797346 --- /dev/null +++ b/docs/python/p0004.rst @@ -0,0 +1,8 @@ +Python Implementation of Problem 4 +================================== + +View source code `here on GitHub! `_ + +.. automodule:: python.p0004 + :members: + :undoc-members: diff --git a/docs/python/p0005.rst b/docs/python/p0005.rst new file mode 100644 index 00000000..fbe73c9f --- /dev/null +++ b/docs/python/p0005.rst @@ -0,0 +1,8 @@ +Python Implementation of Problem 5 +================================== + +View source code `here on GitHub! `_ + +.. automodule:: python.p0005 + :members: + :undoc-members: diff --git a/docs/python/p0006.rst b/docs/python/p0006.rst new file mode 100644 index 00000000..5efca0e8 --- /dev/null +++ b/docs/python/p0006.rst @@ -0,0 +1,8 @@ +Python Implementation of Problem 6 +================================== + +View source code `here on GitHub! `_ + +.. automodule:: python.p0006 + :members: + :undoc-members: diff --git a/docs/python/p0007.rst b/docs/python/p0007.rst new file mode 100644 index 00000000..752a7060 --- /dev/null +++ b/docs/python/p0007.rst @@ -0,0 +1,8 @@ +Python Implementation of Problem 7 +================================== + +View source code `here on GitHub! `_ + +.. automodule:: python.p0007 + :members: + :undoc-members: diff --git a/docs/python/p0008.rst b/docs/python/p0008.rst new file mode 100644 index 00000000..a483f270 --- /dev/null +++ b/docs/python/p0008.rst @@ -0,0 +1,8 @@ +Python Implementation of Problem 8 +================================== + +View source code `here on GitHub! `_ + +.. automodule:: python.p0008 + :members: + :undoc-members: diff --git a/docs/python/p0009.rst b/docs/python/p0009.rst new file mode 100644 index 00000000..6dbcbed1 --- /dev/null +++ b/docs/python/p0009.rst @@ -0,0 +1,8 @@ +Python Implementation of Problem 9 +================================== + +View source code `here on GitHub! `_ + +.. automodule:: python.p0009 + :members: + :undoc-members: diff --git a/docs/python/p0010.rst b/docs/python/p0010.rst new file mode 100644 index 00000000..5877fc7a --- /dev/null +++ b/docs/python/p0010.rst @@ -0,0 +1,8 @@ +Python Implementation of Problem 10 +=================================== + +View source code `here on GitHub! `_ + +.. automodule:: python.p0010 + :members: + :undoc-members: diff --git a/docs/python/p0011.rst b/docs/python/p0011.rst new file mode 100644 index 00000000..b4c84779 --- /dev/null +++ b/docs/python/p0011.rst @@ -0,0 +1,8 @@ +Python Implementation of Problem 11 +=================================== + +View source code `here on GitHub! `_ + +.. automodule:: python.p0011 + :members: + :undoc-members: diff --git a/docs/python/p0012.rst b/docs/python/p0012.rst new file mode 100644 index 00000000..59dcfd4b --- /dev/null +++ b/docs/python/p0012.rst @@ -0,0 +1,8 @@ +Python Implementation of Problem 12 +=================================== + +View source code `here on GitHub! `_ + +.. automodule:: python.p0012 + :members: + :undoc-members: diff --git a/docs/python/p0013.rst b/docs/python/p0013.rst new file mode 100644 index 00000000..b0541505 --- /dev/null +++ b/docs/python/p0013.rst @@ -0,0 +1,8 @@ +Python Implementation of Problem 13 +=================================== + +View source code `here on GitHub! `_ + +.. automodule:: python.p0013 + :members: + :undoc-members: diff --git a/docs/python/p0014.rst b/docs/python/p0014.rst new file mode 100644 index 00000000..e098ba52 --- /dev/null +++ b/docs/python/p0014.rst @@ -0,0 +1,8 @@ +Python Implementation of Problem 14 +=================================== + +View source code `here on GitHub! `_ + +.. automodule:: python.p0014 + :members: + :undoc-members: diff --git a/docs/python/p0015.rst b/docs/python/p0015.rst new file mode 100644 index 00000000..7f0ecf77 --- /dev/null +++ b/docs/python/p0015.rst @@ -0,0 +1,8 @@ +Python Implementation of Problem 15 +=================================== + +View source code `here on GitHub! `_ + +.. automodule:: python.p0015 + :members: + :undoc-members: diff --git a/docs/python/p0016.rst b/docs/python/p0016.rst new file mode 100644 index 00000000..45d3a571 --- /dev/null +++ b/docs/python/p0016.rst @@ -0,0 +1,8 @@ +Python Implementation of Problem 16 +=================================== + +View source code `here on GitHub! `_ + +.. automodule:: python.p0016 + :members: + :undoc-members: diff --git a/docs/python/p0017.rst b/docs/python/p0017.rst new file mode 100644 index 00000000..dad7178b --- /dev/null +++ b/docs/python/p0017.rst @@ -0,0 +1,8 @@ +Python Implementation of Problem 17 +=================================== + +View source code `here on GitHub! `_ + +.. automodule:: python.p0017 + :members: + :undoc-members: diff --git a/docs/python/p0018.rst b/docs/python/p0018.rst new file mode 100644 index 00000000..c293f33e --- /dev/null +++ b/docs/python/p0018.rst @@ -0,0 +1,8 @@ +Python Implementation of Problem 18 +=================================== + +View source code `here on GitHub! `_ + +.. automodule:: python.p0018 + :members: + :undoc-members: diff --git a/docs/python/p0019.rst b/docs/python/p0019.rst new file mode 100644 index 00000000..1f8a4d56 --- /dev/null +++ b/docs/python/p0019.rst @@ -0,0 +1,8 @@ +Python Implementation of Problem 19 +=================================== + +View source code `here on GitHub! `_ + +.. automodule:: python.p0019 + :members: + :undoc-members: diff --git a/docs/python/p0020.rst b/docs/python/p0020.rst new file mode 100644 index 00000000..34c3dcbb --- /dev/null +++ b/docs/python/p0020.rst @@ -0,0 +1,8 @@ +Python Implementation of Problem 20 +=================================== + +View source code `here on GitHub! `_ + +.. automodule:: python.p0020 + :members: + :undoc-members: diff --git a/docs/python/p0021.rst b/docs/python/p0021.rst new file mode 100644 index 00000000..25da87af --- /dev/null +++ b/docs/python/p0021.rst @@ -0,0 +1,8 @@ +Python Implementation of Problem 21 +=================================== + +View source code `here on GitHub! `_ + +.. automodule:: python.p0021 + :members: + :undoc-members: diff --git a/docs/python/p0022.rst b/docs/python/p0022.rst new file mode 100644 index 00000000..acecc01c --- /dev/null +++ b/docs/python/p0022.rst @@ -0,0 +1,8 @@ +Python Implementation of Problem 22 +=================================== + +View source code `here on GitHub! `_ + +.. automodule:: python.p0022 + :members: + :undoc-members: diff --git a/docs/python/p0023.rst b/docs/python/p0023.rst new file mode 100644 index 00000000..b9286e7b --- /dev/null +++ b/docs/python/p0023.rst @@ -0,0 +1,8 @@ +Python Implementation of Problem 23 +=================================== + +View source code `here on GitHub! `_ + +.. automodule:: python.p0023 + :members: + :undoc-members: diff --git a/docs/python/p0024.rst b/docs/python/p0024.rst new file mode 100644 index 00000000..526cd6ca --- /dev/null +++ b/docs/python/p0024.rst @@ -0,0 +1,8 @@ +Python Implementation of Problem 24 +=================================== + +View source code `here on GitHub! `_ + +.. automodule:: python.p0024 + :members: + :undoc-members: diff --git a/docs/python/p0025.rst b/docs/python/p0025.rst new file mode 100644 index 00000000..62c719b9 --- /dev/null +++ b/docs/python/p0025.rst @@ -0,0 +1,8 @@ +Python Implementation of Problem 25 +=================================== + +View source code `here on GitHub! `_ + +.. automodule:: python.p0025 + :members: + :undoc-members: diff --git a/docs/python/p0027.rst b/docs/python/p0027.rst new file mode 100644 index 00000000..d49a068e --- /dev/null +++ b/docs/python/p0027.rst @@ -0,0 +1,8 @@ +Python Implementation of Problem 27 +=================================== + +View source code `here on GitHub! `_ + +.. automodule:: python.p0027 + :members: + :undoc-members: diff --git a/docs/python/p0029.rst b/docs/python/p0029.rst new file mode 100644 index 00000000..c0a4b000 --- /dev/null +++ b/docs/python/p0029.rst @@ -0,0 +1,8 @@ +Python Implementation of Problem 29 +=================================== + +View source code `here on GitHub! `_ + +.. automodule:: python.p0029 + :members: + :undoc-members: diff --git a/docs/python/p0030.rst b/docs/python/p0030.rst new file mode 100644 index 00000000..03699e85 --- /dev/null +++ b/docs/python/p0030.rst @@ -0,0 +1,8 @@ +Python Implementation of Problem 30 +=================================== + +View source code `here on GitHub! `_ + +.. automodule:: python.p0030 + :members: + :undoc-members: diff --git a/docs/python/p0031.rst b/docs/python/p0031.rst new file mode 100644 index 00000000..026ea494 --- /dev/null +++ b/docs/python/p0031.rst @@ -0,0 +1,8 @@ +Python Implementation of Problem 31 +=================================== + +View source code `here on GitHub! `_ + +.. automodule:: python.p0031 + :members: + :undoc-members: diff --git a/docs/python/p0032.rst b/docs/python/p0032.rst new file mode 100644 index 00000000..4da4846f --- /dev/null +++ b/docs/python/p0032.rst @@ -0,0 +1,8 @@ +Python Implementation of Problem 32 +=================================== + +View source code `here on GitHub! `_ + +.. automodule:: python.p0032 + :members: + :undoc-members: diff --git a/docs/python/p0033.rst b/docs/python/p0033.rst new file mode 100644 index 00000000..6c029781 --- /dev/null +++ b/docs/python/p0033.rst @@ -0,0 +1,8 @@ +Python Implementation of Problem 33 +=================================== + +View source code `here on GitHub! `_ + +.. automodule:: python.p0033 + :members: + :undoc-members: diff --git a/docs/python/p0034.rst b/docs/python/p0034.rst new file mode 100644 index 00000000..10573269 --- /dev/null +++ b/docs/python/p0034.rst @@ -0,0 +1,8 @@ +Python Implementation of Problem 34 +=================================== + +View source code `here on GitHub! `_ + +.. automodule:: python.p0034 + :members: + :undoc-members: diff --git a/docs/python/p0035.rst b/docs/python/p0035.rst new file mode 100644 index 00000000..2f79bf71 --- /dev/null +++ b/docs/python/p0035.rst @@ -0,0 +1,8 @@ +Python Implementation of Problem 35 +=================================== + +View source code `here on GitHub! `_ + +.. automodule:: python.p0035 + :members: + :undoc-members: diff --git a/docs/python/p0036.rst b/docs/python/p0036.rst new file mode 100644 index 00000000..ff66616f --- /dev/null +++ b/docs/python/p0036.rst @@ -0,0 +1,8 @@ +Python Implementation of Problem 36 +=================================== + +View source code `here on GitHub! `_ + +.. automodule:: python.p0036 + :members: + :undoc-members: diff --git a/docs/python/p0037.rst b/docs/python/p0037.rst new file mode 100644 index 00000000..9b42fee7 --- /dev/null +++ b/docs/python/p0037.rst @@ -0,0 +1,8 @@ +Python Implementation of Problem 37 +=================================== + +View source code `here on GitHub! `_ + +.. automodule:: python.p0037 + :members: + :undoc-members: diff --git a/docs/python/p0038.rst b/docs/python/p0038.rst new file mode 100644 index 00000000..9288af14 --- /dev/null +++ b/docs/python/p0038.rst @@ -0,0 +1,8 @@ +Python Implementation of Problem 38 +=================================== + +View source code `here on GitHub! `_ + +.. automodule:: python.p0038 + :members: + :undoc-members: diff --git a/docs/python/p0039.rst b/docs/python/p0039.rst new file mode 100644 index 00000000..57bc78e3 --- /dev/null +++ b/docs/python/p0039.rst @@ -0,0 +1,8 @@ +Python Implementation of Problem 39 +=================================== + +View source code `here on GitHub! `_ + +.. automodule:: python.p0039 + :members: + :undoc-members: diff --git a/docs/python/p0040.rst b/docs/python/p0040.rst new file mode 100644 index 00000000..f1f2885d --- /dev/null +++ b/docs/python/p0040.rst @@ -0,0 +1,8 @@ +Python Implementation of Problem 40 +=================================== + +View source code `here on GitHub! `_ + +.. automodule:: python.p0040 + :members: + :undoc-members: diff --git a/docs/python/p0041.rst b/docs/python/p0041.rst new file mode 100644 index 00000000..4cd7957a --- /dev/null +++ b/docs/python/p0041.rst @@ -0,0 +1,8 @@ +Python Implementation of Problem 41 +=================================== + +View source code `here on GitHub! `_ + +.. automodule:: python.p0041 + :members: + :undoc-members: diff --git a/docs/python/p0042.rst b/docs/python/p0042.rst new file mode 100644 index 00000000..c536b987 --- /dev/null +++ b/docs/python/p0042.rst @@ -0,0 +1,8 @@ +Python Implementation of Problem 42 +=================================== + +View source code `here on GitHub! `_ + +.. automodule:: python.p0042 + :members: + :undoc-members: diff --git a/docs/python/p0043.rst b/docs/python/p0043.rst new file mode 100644 index 00000000..5f27f579 --- /dev/null +++ b/docs/python/p0043.rst @@ -0,0 +1,8 @@ +Python Implementation of Problem 43 +=================================== + +View source code `here on GitHub! `_ + +.. automodule:: python.p0043 + :members: + :undoc-members: diff --git a/docs/python/p0044.rst b/docs/python/p0044.rst new file mode 100644 index 00000000..05e3b60b --- /dev/null +++ b/docs/python/p0044.rst @@ -0,0 +1,8 @@ +Python Implementation of Problem 44 +=================================== + +View source code `here on GitHub! `_ + +.. automodule:: python.p0044 + :members: + :undoc-members: diff --git a/docs/python/p0045.rst b/docs/python/p0045.rst new file mode 100644 index 00000000..68a436ac --- /dev/null +++ b/docs/python/p0045.rst @@ -0,0 +1,8 @@ +Python Implementation of Problem 45 +=================================== + +View source code `here on GitHub! `_ + +.. automodule:: python.p0045 + :members: + :undoc-members: diff --git a/docs/python/p0046.rst b/docs/python/p0046.rst new file mode 100644 index 00000000..f49611f3 --- /dev/null +++ b/docs/python/p0046.rst @@ -0,0 +1,8 @@ +Python Implementation of Problem 46 +=================================== + +View source code `here on GitHub! `_ + +.. automodule:: python.p0046 + :members: + :undoc-members: diff --git a/docs/python/p0047.rst b/docs/python/p0047.rst new file mode 100644 index 00000000..4dc9c991 --- /dev/null +++ b/docs/python/p0047.rst @@ -0,0 +1,8 @@ +Python Implementation of Problem 47 +=================================== + +View source code `here on GitHub! `_ + +.. automodule:: python.p0047 + :members: + :undoc-members: diff --git a/docs/python/p0048.rst b/docs/python/p0048.rst new file mode 100644 index 00000000..fc0c8da9 --- /dev/null +++ b/docs/python/p0048.rst @@ -0,0 +1,8 @@ +Python Implementation of Problem 48 +=================================== + +View source code `here on GitHub! `_ + +.. automodule:: python.p0048 + :members: + :undoc-members: diff --git a/docs/python/p0049.rst b/docs/python/p0049.rst new file mode 100644 index 00000000..dff16d6c --- /dev/null +++ b/docs/python/p0049.rst @@ -0,0 +1,8 @@ +Python Implementation of Problem 49 +=================================== + +View source code `here on GitHub! `_ + +.. automodule:: python.p0049 + :members: + :undoc-members: diff --git a/docs/python/p0050.rst b/docs/python/p0050.rst new file mode 100644 index 00000000..826a353a --- /dev/null +++ b/docs/python/p0050.rst @@ -0,0 +1,8 @@ +Python Implementation of Problem 50 +=================================== + +View source code `here on GitHub! `_ + +.. automodule:: python.p0050 + :members: + :undoc-members: diff --git a/docs/python/p0052.rst b/docs/python/p0052.rst new file mode 100644 index 00000000..4a0a8754 --- /dev/null +++ b/docs/python/p0052.rst @@ -0,0 +1,8 @@ +Python Implementation of Problem 52 +=================================== + +View source code `here on GitHub! `_ + +.. automodule:: python.p0052 + :members: + :undoc-members: diff --git a/docs/python/p0053.rst b/docs/python/p0053.rst new file mode 100644 index 00000000..23fab2f6 --- /dev/null +++ b/docs/python/p0053.rst @@ -0,0 +1,8 @@ +Python Implementation of Problem 53 +=================================== + +View source code `here on GitHub! `_ + +.. automodule:: python.p0053 + :members: + :undoc-members: diff --git a/docs/python/p0055.rst b/docs/python/p0055.rst new file mode 100644 index 00000000..f7f49dec --- /dev/null +++ b/docs/python/p0055.rst @@ -0,0 +1,8 @@ +Python Implementation of Problem 55 +=================================== + +View source code `here on GitHub! `_ + +.. automodule:: python.p0055 + :members: + :undoc-members: diff --git a/docs/python/p0056.rst b/docs/python/p0056.rst new file mode 100644 index 00000000..a81d13af --- /dev/null +++ b/docs/python/p0056.rst @@ -0,0 +1,8 @@ +Python Implementation of Problem 56 +=================================== + +View source code `here on GitHub! `_ + +.. automodule:: python.p0056 + :members: + :undoc-members: diff --git a/docs/python/p0057.rst b/docs/python/p0057.rst new file mode 100644 index 00000000..a180065a --- /dev/null +++ b/docs/python/p0057.rst @@ -0,0 +1,8 @@ +Python Implementation of Problem 57 +=================================== + +View source code `here on GitHub! `_ + +.. automodule:: python.p0057 + :members: + :undoc-members: diff --git a/docs/python/p0059.rst b/docs/python/p0059.rst new file mode 100644 index 00000000..4422bed2 --- /dev/null +++ b/docs/python/p0059.rst @@ -0,0 +1,8 @@ +Python Implementation of Problem 59 +=================================== + +View source code `here on GitHub! `_ + +.. automodule:: python.p0059 + :members: + :undoc-members: diff --git a/docs/python/p0067.rst b/docs/python/p0067.rst new file mode 100644 index 00000000..0612a148 --- /dev/null +++ b/docs/python/p0067.rst @@ -0,0 +1,8 @@ +Python Implementation of Problem 67 +=================================== + +View source code `here on GitHub! `_ + +.. automodule:: python.p0067 + :members: + :undoc-members: diff --git a/docs/python/p0069.rst b/docs/python/p0069.rst new file mode 100644 index 00000000..2c82087b --- /dev/null +++ b/docs/python/p0069.rst @@ -0,0 +1,8 @@ +Python Implementation of Problem 69 +=================================== + +View source code `here on GitHub! `_ + +.. automodule:: python.p0069 + :members: + :undoc-members: diff --git a/docs/python/p0071.rst b/docs/python/p0071.rst new file mode 100644 index 00000000..b1dd70d8 --- /dev/null +++ b/docs/python/p0071.rst @@ -0,0 +1,8 @@ +Python Implementation of Problem 71 +=================================== + +View source code `here on GitHub! `_ + +.. automodule:: python.p0071 + :members: + :undoc-members: diff --git a/docs/python/p0073.rst b/docs/python/p0073.rst new file mode 100644 index 00000000..d4c0a42e --- /dev/null +++ b/docs/python/p0073.rst @@ -0,0 +1,8 @@ +Python Implementation of Problem 73 +=================================== + +View source code `here on GitHub! `_ + +.. automodule:: python.p0073 + :members: + :undoc-members: diff --git a/docs/python/p0074.rst b/docs/python/p0074.rst new file mode 100644 index 00000000..95df6944 --- /dev/null +++ b/docs/python/p0074.rst @@ -0,0 +1,8 @@ +Python Implementation of Problem 74 +=================================== + +View source code `here on GitHub! `_ + +.. automodule:: python.p0074 + :members: + :undoc-members: diff --git a/docs/python/p0076.rst b/docs/python/p0076.rst new file mode 100644 index 00000000..2a2825cf --- /dev/null +++ b/docs/python/p0076.rst @@ -0,0 +1,8 @@ +Python Implementation of Problem 76 +=================================== + +View source code `here on GitHub! `_ + +.. automodule:: python.p0076 + :members: + :undoc-members: diff --git a/docs/python/p0077.rst b/docs/python/p0077.rst new file mode 100644 index 00000000..d4d29151 --- /dev/null +++ b/docs/python/p0077.rst @@ -0,0 +1,8 @@ +Python Implementation of Problem 77 +=================================== + +View source code `here on GitHub! `_ + +.. automodule:: python.p0077 + :members: + :undoc-members: diff --git a/docs/python/p0087.rst b/docs/python/p0087.rst new file mode 100644 index 00000000..99641733 --- /dev/null +++ b/docs/python/p0087.rst @@ -0,0 +1,8 @@ +Python Implementation of Problem 87 +=================================== + +View source code `here on GitHub! `_ + +.. automodule:: python.p0087 + :members: + :undoc-members: diff --git a/docs/python/p0092.rst b/docs/python/p0092.rst new file mode 100644 index 00000000..6ecdf698 --- /dev/null +++ b/docs/python/p0092.rst @@ -0,0 +1,8 @@ +Python Implementation of Problem 92 +=================================== + +View source code `here on GitHub! `_ + +.. automodule:: python.p0092 + :members: + :undoc-members: diff --git a/docs/python/p0097.rst b/docs/python/p0097.rst new file mode 100644 index 00000000..31a3ccdb --- /dev/null +++ b/docs/python/p0097.rst @@ -0,0 +1,8 @@ +Python Implementation of Problem 97 +=================================== + +View source code `here on GitHub! `_ + +.. automodule:: python.p0097 + :members: + :undoc-members: diff --git a/docs/python/p0118.rst b/docs/python/p0118.rst new file mode 100644 index 00000000..a1f848ea --- /dev/null +++ b/docs/python/p0118.rst @@ -0,0 +1,8 @@ +Python Implementation of Problem 118 +==================================== + +View source code `here on GitHub! `_ + +.. automodule:: python.p0118 + :members: + :undoc-members: diff --git a/docs/python/p0123.rst b/docs/python/p0123.rst new file mode 100644 index 00000000..18ff13af --- /dev/null +++ b/docs/python/p0123.rst @@ -0,0 +1,8 @@ +Python Implementation of Problem 123 +==================================== + +View source code `here on GitHub! `_ + +.. automodule:: python.p0123 + :members: + :undoc-members: diff --git a/docs/python/p0134.rst b/docs/python/p0134.rst new file mode 100644 index 00000000..41bb705b --- /dev/null +++ b/docs/python/p0134.rst @@ -0,0 +1,8 @@ +Python Implementation of Problem 134 +==================================== + +View source code `here on GitHub! `_ + +.. automodule:: python.p0134 + :members: + :undoc-members: diff --git a/docs/python/p0145.rst b/docs/python/p0145.rst new file mode 100644 index 00000000..d67e7d0b --- /dev/null +++ b/docs/python/p0145.rst @@ -0,0 +1,8 @@ +Python Implementation of Problem 145 +==================================== + +View source code `here on GitHub! `_ + +.. automodule:: python.p0145 + :members: + :undoc-members: diff --git a/docs/python/p0187.rst b/docs/python/p0187.rst new file mode 100644 index 00000000..74bfae29 --- /dev/null +++ b/docs/python/p0187.rst @@ -0,0 +1,8 @@ +Python Implementation of Problem 187 +==================================== + +View source code `here on GitHub! `_ + +.. automodule:: python.p0187 + :members: + :undoc-members: diff --git a/docs/python/p0206.rst b/docs/python/p0206.rst new file mode 100644 index 00000000..1fabbdef --- /dev/null +++ b/docs/python/p0206.rst @@ -0,0 +1,8 @@ +Python Implementation of Problem 206 +==================================== + +View source code `here on GitHub! `_ + +.. automodule:: python.p0206 + :members: + :undoc-members: diff --git a/docs/requirements.txt b/docs/requirements.txt new file mode 100644 index 00000000..93e1cf43 --- /dev/null +++ b/docs/requirements.txt @@ -0,0 +1,3 @@ +sphinx +sphinx-rtd-theme +sphinx-git \ No newline at end of file diff --git a/docs/usage.rst b/docs/usage.rst new file mode 100644 index 00000000..627840fb --- /dev/null +++ b/docs/usage.rst @@ -0,0 +1,11 @@ +Euler Usage +=========== + +This repo includes solutions in the following languages: + +.. include:: ../README.rst + :start-line: 2 + :end-before: This is the repository + +.. include:: ../README.rst + :start-after: If you are working on Project Euler problems, DO NOT use this as a source \ No newline at end of file diff --git a/javascript/README.md b/javascript/README.md deleted file mode 100644 index 223e01c6..00000000 --- a/javascript/README.md +++ /dev/null @@ -1,40 +0,0 @@ -# JavaScript Section - -[![JavaScript Check](https://github.com/LivInTheLookingGlass/Euler/actions/workflows/javascript.yml/badge.svg)](https://github.com/LivInTheLookingGlass/Euler/actions/workflows/javascript.yml) - -All problems are solved in ES6+ Javascript - -## Organization - -All javascript files share a common prefix with their problem number. Though it is currently not the case, some of these files may export utilities for other problems to use. - -## Makefile - -There are two main recipes in this Makefile - -### dependencies - -This recipe installs all the required and test dependencies. See the Dependencies section for more info - -### test - -This recipe runs tests in a single thread and performs benchmarks on each. This test infrastructure is based on mocha and benchmark.js, though it currently does not export benchmark info except to fail tests for time limit reasons. - -## Tests - -### Generic Problems - -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\*. - -\* This is a TODO for the Javascript section - -A test fails if it gets the wrong answer or if it takes more than 1 minute. - -## Dependencies - -I try to keep the dependencies of this project as small as possible, except for test plugins. At the moment there are no non-test dependencies for this section. - -## Problems Solved - -- [x] [1](./p0001.js) -- [x] [2](./p0002.js) diff --git a/javascript/README.rst b/javascript/README.rst new file mode 100644 index 00000000..50d2dead --- /dev/null +++ b/javascript/README.rst @@ -0,0 +1,64 @@ +JavaScript Section +================== + +.. |JavaScript Check| image:: https://github.com/LivInTheLookingGlass/Euler/actions/workflows/javascript.yml/badge.svg + :target: https://github.com/LivInTheLookingGlass/Euler/actions/workflows/javascript.yml + +|JavaScript Check| + +All problems are solved in ES6+ Javascript + +Organization +------------ + +All javascript files share a common prefix with their problem number. +Though it is currently not the case, some of these files may export +utilities for other problems to use. + +Makefile +-------- + +There are two main recipes in this Makefile + +dependencies +~~~~~~~~~~~~ + +This recipe installs all the required and test dependencies. See the +Dependencies section for more info + +test +~~~~ + +This recipe runs tests in a single thread and performs benchmarks on +each. This test infrastructure is based on mocha and benchmark.js, +though it currently does not export benchmark info except to fail tests +for time limit reasons. + +Tests +----- + +Generic Problems +~~~~~~~~~~~~~~~~ + +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*. + +\* This is a TODO for the Javascript section + +A test fails if it gets the wrong answer or if it takes more than 1 +minute. + +Dependencies +------------ + +I try to keep the dependencies of this project as small as possible, +except for test plugins. At the moment there are no non-test +dependencies for this section. + +Problems Solved +--------------- + +- ☒ `1 <./p0001.js>`__ +- ☒ `2 <./p0002.js>`__ diff --git a/python/README.md b/python/README.md deleted file mode 100644 index 8c617c01..00000000 --- a/python/README.md +++ /dev/null @@ -1,153 +0,0 @@ -# Python Section - -[![Python Check](https://github.com/LivInTheLookingGlass/Euler/actions/workflows/python.yml/badge.svg)](https://github.com/LivInTheLookingGlass/Euler/actions/workflows/python.yml) - -All problems are solved in type-hinted python3 - -## Organization - -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): - -* p0002 for the fibonacci sequence -* p0003 for prime numbers and factors -* p0004 for palindrome detection -* p0007 for is_prime() -* p0008 for iterating over a series in groups of n -* p0015 for n_choose_r -* p0018 for trianglar pathfinding - * only used by p0018 and p0067 -* p0021 for proper divisors -* p0052 and p0074 for digits functions - * p0052 for a sequence - * p0074 for a generator -* p0055 for retrieving a number from its digits - -## Makefile - -There are three main recipes in this Makefile - -### dependencies - -This recipe installs all the required and test dependencies. See the Dependencies section for more info - -### test - -This recipe runs tests in a single thread and performs benchmarks and style checks on them. - -### test_* - -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. - -## Tests - -### Prime Numbers - -There is a single test for the prime number infrastructure. It has three components: - -1. It checks that it correctly generates the first million primes in the correct order -2. It checks that is_prime() operates correctly for all numbers in that range, including all composites between them -3. It checks that the whole series takes <200ns/prime to compute - -### Generic Problems - -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. - -## Dependencies - -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: - -### u-msgpack-python - -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. - -### sortedcontainers - -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. - -## Environment Variables - -### NO_OPTIONAL_TESTS - -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`](#only-slow). - -### NO_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`](#no-slow) and [`ONLY_SLOW`](#only-slow) are truthy, they will be ignored and a warning will be issued. - -### ONLY_SLOW - -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`](#no-slow) and [`ONLY_SLOW`](#only-slow) are truthy, they will be ignored and a warning will be issued. -## Problems Solved - -- [x] [1](./p0001.py) -- [x] [2](./p0002.py) -- [x] [3](./p0003.py) -- [x] [4](./p0004.py) -- [x] [5](./p0005.py) -- [x] [6](./p0006.py) -- [x] [7](./p0007.py) -- [x] [8](./p0008.py) -- [x] [9](./p0009.py) -- [x] [10](./p0010.py) -- [x] [11](./p0011.py) -- [x] [12](./p0012.py) -- [x] [13](./p0013.py) -- [x] [14](./p0014.py) -- [x] [15](./p0015.py) -- [x] [16](./p0016.py) -- [x] [17](./p0017.py) -- [x] [18](./p0018.py) -- [x] [19](./p0019.py) -- [x] [20](./p0020.py) -- [x] [21](./p0021.py) -- [x] [22](./p0022.py) -- [x] [23](./p0023.py) -- [x] [24](./p0024.py) -- [x] [25](./p0025.py) -- [x] [27](./p0027.py) -- [x] [29](./p0029.py) -- [x] [30](./p0030.py) -- [x] [31](./p0031.py) -- [x] [32](./p0032.py) -- [x] [33](./p0033.py) -- [x] [34](./p0034.py) -- [x] [35](./p0035.py) -- [x] [36](./p0036.py) -- [x] [37](./p0037.py) -- [x] [38](./p0038.py) -- [x] [39](./p0039.py) -- [x] [40](./p0040.py) -- [x] [41](./p0041.py) -- [x] [42](./p0042.py) -- [x] [43](./p0043.py) -- [x] [44](./p0044.py) -- [x] [45](./p0045.py) -- [x] [46](./p0046.py) -- [x] [47](./p0047.py) -- [x] [48](./p0048.py) -- [x] [49](./p0049.py) -- [x] [50](./p0050.py) -- [x] [52](./p0052.py) -- [x] [53](./p0053.py) -- [x] [55](./p0055.py) -- [x] [56](./p0056.py) -- [x] [57](./p0057.py) -- [x] [59](./p0059.py) -- [x] [67](./p0067.py) -- [x] [69](./p0069.py) -- [x] [71](./p0071.py) -- [x] [73](./p0073.py) -- [x] [74](./p0074.py) -- [x] [76](./p0076.py) -- [x] [77](./p0077.py) -- [x] [87](./p0087.py) -- [x] [92](./p0092.py) -- [x] [98](./p0098.py) -- [x] [118](./p0118.py) -- [x] [123](./p0123.py) -- [x] [134](./p0134.py) -- [x] [145](./p0145.py) -- [x] [187](./p0187.py) -- [x] [206](./p0206.py) diff --git a/python/README.rst b/python/README.rst new file mode 100644 index 00000000..cdd787d1 --- /dev/null +++ b/python/README.rst @@ -0,0 +1,209 @@ +Python Section +============== + +.. |Python Check| image:: https://github.com/LivInTheLookingGlass/Euler/actions/workflows/python.yml/badge.svg + :target: https://github.com/LivInTheLookingGlass/Euler/actions/workflows/python.yml + +|Python Check| + +All problems are solved in type-hinted python3 + +Organization +------------ + +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): + +- p0002 for the fibonacci sequence +- p0003 for prime numbers and factors +- p0004 for palindrome detection +- p0007 for is_prime() +- p0008 for iterating over a series in groups of n +- p0015 for n_choose_r +- p0018 for trianglar pathfinding + + - only used by p0018 and p0067 +- p0021 for proper divisors +- p0052 and p0074 for digits functions + + - p0052 for a sequence + - p0074 for a generator +- p0055 for retrieving a number from its digits + +Makefile +-------- + +There are three main recipes in this Makefile + +dependencies +~~~~~~~~~~~~ + +This recipe installs all the required and test dependencies. See the +Dependencies section for more info + +test +~~~~ + +This recipe runs tests in a single thread and performs benchmarks and +style checks on them. + +test\_\* +~~~~~~~~ + +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. + +Tests +----- + +Prime Numbers +~~~~~~~~~~~~~ + +There is a single test for the prime number infrastructure. It has three +components: + +1. It checks that it correctly generates the first million primes in the + correct order +2. It checks that is_prime() operates correctly for all numbers in that + range, including all composites between them +3. It checks that the whole series takes <200ns/prime to compute + +Generic Problems +~~~~~~~~~~~~~~~~ + +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. + +Dependencies +------------ + +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: + +u-msgpack-python +~~~~~~~~~~~~~~~~ + +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. + +sortedcontainers +~~~~~~~~~~~~~~~~ + +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. + +Environment Variables +--------------------- + +NO_OPTIONAL_TESTS +~~~~~~~~~~~~~~~~~ + +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 <#only-slow>`__. + +NO_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 <#no-slow>`__ and `ONLY_SLOW <#only-slow>`__ are +truthy, they will be ignored and a warning will be issued. + +ONLY_SLOW +~~~~~~~~~ + +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 <#no-slow>`__ and `ONLY_SLOW <#only-slow>`__ are +truthy, they will be ignored and a warning will be issued. + +Problems Solved +--------------- + +- ☒ `1 <./p0001.py>`__ +- ☒ `2 <./p0002.py>`__ +- ☒ `3 <./p0003.py>`__ +- ☒ `4 <./p0004.py>`__ +- ☒ `5 <./p0005.py>`__ +- ☒ `6 <./p0006.py>`__ +- ☒ `7 <./p0007.py>`__ +- ☒ `8 <./p0008.py>`__ +- ☒ `9 <./p0009.py>`__ +- ☒ `10 <./p0010.py>`__ +- ☒ `11 <./p0011.py>`__ +- ☒ `12 <./p0012.py>`__ +- ☒ `13 <./p0013.py>`__ +- ☒ `14 <./p0014.py>`__ +- ☒ `15 <./p0015.py>`__ +- ☒ `16 <./p0016.py>`__ +- ☒ `17 <./p0017.py>`__ +- ☒ `18 <./p0018.py>`__ +- ☒ `19 <./p0019.py>`__ +- ☒ `20 <./p0020.py>`__ +- ☒ `21 <./p0021.py>`__ +- ☒ `22 <./p0022.py>`__ +- ☒ `23 <./p0023.py>`__ +- ☒ `24 <./p0024.py>`__ +- ☒ `25 <./p0025.py>`__ +- ☒ `27 <./p0027.py>`__ +- ☒ `29 <./p0029.py>`__ +- ☒ `30 <./p0030.py>`__ +- ☒ `31 <./p0031.py>`__ +- ☒ `32 <./p0032.py>`__ +- ☒ `33 <./p0033.py>`__ +- ☒ `34 <./p0034.py>`__ +- ☒ `35 <./p0035.py>`__ +- ☒ `36 <./p0036.py>`__ +- ☒ `37 <./p0037.py>`__ +- ☒ `38 <./p0038.py>`__ +- ☒ `39 <./p0039.py>`__ +- ☒ `40 <./p0040.py>`__ +- ☒ `41 <./p0041.py>`__ +- ☒ `42 <./p0042.py>`__ +- ☒ `43 <./p0043.py>`__ +- ☒ `44 <./p0044.py>`__ +- ☒ `45 <./p0045.py>`__ +- ☒ `46 <./p0046.py>`__ +- ☒ `47 <./p0047.py>`__ +- ☒ `48 <./p0048.py>`__ +- ☒ `49 <./p0049.py>`__ +- ☒ `50 <./p0050.py>`__ +- ☒ `52 <./p0052.py>`__ +- ☒ `53 <./p0053.py>`__ +- ☒ `55 <./p0055.py>`__ +- ☒ `56 <./p0056.py>`__ +- ☒ `57 <./p0057.py>`__ +- ☒ `59 <./p0059.py>`__ +- ☒ `67 <./p0067.py>`__ +- ☒ `69 <./p0069.py>`__ +- ☒ `71 <./p0071.py>`__ +- ☒ `73 <./p0073.py>`__ +- ☒ `74 <./p0074.py>`__ +- ☒ `76 <./p0076.py>`__ +- ☒ `77 <./p0077.py>`__ +- ☒ `87 <./p0087.py>`__ +- ☒ `92 <./p0092.py>`__ +- ☒ `98 <./p0098.py>`__ +- ☒ `118 <./p0118.py>`__ +- ☒ `123 <./p0123.py>`__ +- ☒ `134 <./p0134.py>`__ +- ☒ `145 <./p0145.py>`__ +- ☒ `187 <./p0187.py>`__ +- ☒ `206 <./p0206.py>`__ diff --git a/python/p0012.py b/python/p0012.py index 0e2b61a7..41cd893f 100644 --- a/python/p0012.py +++ b/python/p0012.py @@ -14,6 +14,8 @@ Let us list the factors of the first seven triangle numbers: +.. code-block:: + 1: 1 3: 1,3 6: 1,2,3,6 diff --git a/python/p0018.py b/python/p0018.py index d8b5be1f..8b4431b2 100644 --- a/python/p0018.py +++ b/python/p0018.py @@ -8,30 +8,34 @@ By starting at the top of the triangle below and moving to adjacent numbers on the row below, the maximum total from top to bottom is 23. - 3 - 7 4 - 2 4 6 -8 5 9 3 +.. code-block:: + + 3 + 7 4 + 2 4 6 + 8 5 9 3 That is, 3 + 7 + 4 + 9 = 23. Find the maximum total from top to bottom of the triangle below: - 75 - 95 64 - 17 47 82 - 18 35 87 10 - 20 04 82 47 65 - 19 01 23 75 03 34 - 88 02 77 73 07 63 67 - 99 65 04 28 06 16 70 92 - 41 41 26 56 83 40 80 70 33 - 41 48 72 33 47 32 37 16 94 29 - 53 71 44 65 25 43 91 52 97 51 14 - 70 11 33 28 77 73 17 78 39 68 17 57 - 91 71 52 38 17 14 91 43 58 50 27 29 48 - 63 66 04 68 89 53 67 30 73 16 69 87 40 31 -04 62 98 27 23 09 70 98 73 93 38 53 60 04 23 +.. code-block:: + + 75 + 95 64 + 17 47 82 + 18 35 87 10 + 20 04 82 47 65 + 19 01 23 75 03 34 + 88 02 77 73 07 63 67 + 99 65 04 28 06 16 70 92 + 41 41 26 56 83 40 80 70 33 + 41 48 72 33 47 32 37 16 94 29 + 53 71 44 65 25 43 91 52 97 51 14 + 70 11 33 28 77 73 17 78 39 68 17 57 + 91 71 52 38 17 14 91 43 58 50 27 29 48 + 63 66 04 68 89 53 67 30 73 16 69 87 40 31 + 04 62 98 27 23 09 70 98 73 93 38 53 60 04 23 NOTE: As there are only 16384 routes, it is possible to solve this problem by trying every route. However, Problem 67, is the same challenge with a triangle containing one-hundred rows; it cannot be solved by brute force, and requires a diff --git a/python/p0027.py b/python/p0027.py index 8a08e256..03cd4438 100644 --- a/python/p0027.py +++ b/python/p0027.py @@ -8,10 +8,10 @@ n**2+n+41 It turns out that the formula will produce 40 primes for the consecutive -integer values 0≤n≤39. However, when n=40,40**2+40+41=40(40+1)+41 is divisible -by 41, and certainly when n=41,41**2+41+41 is clearly divisible by 41. +integer values 0≤n≤39. However, when ``n=40``, ``40**2+40+41=40(40+1)+41`` is divisible +by 41, and certainly when ``n=41``, ``41**2+41+41`` is clearly divisible by 41. -The incredible formula n**2−79n+1601 was discovered, which produces 80 primes +The incredible formula ``n**2−79n+1601`` was discovered, which produces 80 primes for the consecutive values 0≤n≤79. The product of the coefficients, −79 and 1601, is −126479. @@ -19,9 +19,9 @@ n**2+an+b -, where |a|<1000 and |b|≤1000 +, where ``|a|<1000`` and ``|b|≤1000`` -where |n| is the modulus/absolute value of n, e.g. |11|=11 and |−4|=4 +where ``|n|`` is the modulus/absolute value of n, e.g. ``|11|=11`` and ``|−4|=4`` Find the product of the coefficients, a and b, for the quadratic expression that produces the maximum number of primes for consecutive values of n,