diff --git a/.github/workflows/c.yml b/.github/workflows/c.yml index 9e733a46..5e3b67c8 100644 --- a/.github/workflows/c.yml +++ b/.github/workflows/c.yml @@ -5,6 +5,7 @@ on: paths-ignore: - 'docs/**' - 'README.rst' + - '**/README.rst' schedule: - cron: "0 0 1 * *" diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index f3409efb..9eb0dbd1 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -20,6 +20,7 @@ on: paths-ignore: - 'docs/**' - 'README.rst' + - '**/README.rst' branches: [ "master" ] pull_request: branches: [ "master" ] diff --git a/.github/workflows/cplusplus.yml b/.github/workflows/cplusplus.yml index 0df18364..ea4c2bdd 100644 --- a/.github/workflows/cplusplus.yml +++ b/.github/workflows/cplusplus.yml @@ -5,6 +5,7 @@ on: paths-ignore: - 'docs/**' - 'README.rst' + - '**/README.rst' schedule: - cron: "0 0 1 * *" diff --git a/.github/workflows/csharp.yml b/.github/workflows/csharp.yml index 2de452a6..27596947 100644 --- a/.github/workflows/csharp.yml +++ b/.github/workflows/csharp.yml @@ -5,6 +5,7 @@ on: paths-ignore: - 'docs/**' - 'README.rst' + - '**/README.rst' schedule: - cron: "0 0 1 * *" diff --git a/.github/workflows/eslint.yml b/.github/workflows/eslint.yml index 002e015b..898a7e74 100644 --- a/.github/workflows/eslint.yml +++ b/.github/workflows/eslint.yml @@ -14,6 +14,7 @@ on: paths-ignore: - 'docs/**' - 'README.rst' + - '**/README.rst' branches: [ "master" ] pull_request: # The branches below must be a subset of the branches above diff --git a/.github/workflows/javascript.yml b/.github/workflows/javascript.yml index f6b918e4..c0e7ef2b 100644 --- a/.github/workflows/javascript.yml +++ b/.github/workflows/javascript.yml @@ -5,13 +5,14 @@ on: paths-ignore: - 'docs/**' - 'README.rst' + - '**/README.rst' schedule: - cron: "0 0 1 * *" concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true - + jobs: javascript: strategy: diff --git a/.github/workflows/python-lint.yml b/.github/workflows/python-lint.yml new file mode 100644 index 00000000..09fe2aea --- /dev/null +++ b/.github/workflows/python-lint.yml @@ -0,0 +1,32 @@ +name: Python-Lint + +on: + push: + paths-ignore: + - 'docs/**' + - 'README.rst' + - '**/README.rst' + schedule: + - cron: "0 0 1 * *" + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + python-lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - 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 + + - name: Lint + run: make pytest LINT=only diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index 52c69b1c..33f376f1 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -5,6 +5,7 @@ on: paths-ignore: - 'docs/**' - 'README.rst' + - '**/README.rst' schedule: - cron: "0 0 1 * *" @@ -13,23 +14,6 @@ concurrency: cancel-in-progress: true jobs: -# python-lint: -# runs-on: ubuntu-latest -# steps: -# - uses: actions/checkout@v3 -# -# - 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 -# -# - name: Lint -# run: make pytest LINT=only - python: strategy: fail-fast: false diff --git a/.github/workflows/rust-clippy.yml b/.github/workflows/rust-clippy.yml index 2fa6b8af..36e766cd 100644 --- a/.github/workflows/rust-clippy.yml +++ b/.github/workflows/rust-clippy.yml @@ -14,6 +14,7 @@ on: paths-ignore: - 'docs/**' - 'README.rst' + - '**/README.rst' branches: [ "master" ] pull_request: # The branches below must be a subset of the branches above @@ -24,7 +25,7 @@ on: concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true - + jobs: rust-clippy-analyze: name: Run rust-clippy analyzing diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 42a12a9e..c623fa7b 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -5,6 +5,7 @@ on: paths-ignore: - 'docs/**' - 'README.rst' + - '**/README.rst' schedule: - cron: "0 0 1 * *" diff --git a/README.rst b/README.rst index b5e8ad13..208be20b 100644 --- a/README.rst +++ b/README.rst @@ -19,6 +19,8 @@ LivInTheLookingGlass’s Project Euler solutions :target: https://github.com/LivInTheLookingGlass/Euler/actions/workflows/eslint.yml .. |RustClippy| image:: https://github.com/LivInTheLookingGlass/Euler/actions/workflows/rust-clippy.yml/badge.svg :target: https://github.com/LivInTheLookingGlass/Euler/actions/workflows/rust-clippy.yml +.. |PythonLint| image:: https://github.com/LivInTheLookingGlass/Euler/actions/workflows/python-lint.yml/badge.svg + :target: https://github.com/LivInTheLookingGlass/Euler/actions/workflows/python-lint.yml .. |Pages| image:: https://github.com/LivInTheLookingGlass/Euler/actions/workflows/pages.yml/badge.svg :target: https://github.com/LivInTheLookingGlass/Euler/actions/workflows/pages.yml .. |Coverage| image:: https://codecov.io/github/LivInTheLookingGlass/Euler/graph/badge.svg?token=6GHBNILEHG @@ -26,35 +28,38 @@ LivInTheLookingGlass’s Project Euler solutions .. |br| raw:: html
- -+------------+---------------------+--------+---------------+ -| Language | Version | Solved | Status | -+============+=====================+========+===============+ -| C | C99+ in: ``gcc``, | 17 | |Ci| | -| | |br| ``clang``, | | | -| | ``msvc``, |br| | | | -| | ``pcc``, ``tcc`` | | | -+------------+---------------------+--------+---------------+ -| C++ | C++98+ | 1 | |Cpi| | -+------------+---------------------+--------+---------------+ -| C# | .NET 2+ | 6 | |C#i| | -+------------+---------------------+--------+---------------+ -| JavaScript | Node 12+ | 5 | |JavaScript| | -+------------+---------------------+--------+---------------+ -| Python | CPython 3.6+ |br| | 70 | |Python| | -| | Pypy 3.6+ |br| | | | -| | GraalPy 23.1+ | | | -+------------+---------------------+--------+---------------+ -| Rust | 1.69+ | 10 | |Rust| | -+------------+---------------------+--------+---------------+ -| Documentation (in progress) | |Pages| | -+-------------------------------------------+---------------+ -| Code Coverage | |Coverage| | -+-------------------------------------------+---------------+ -| Code Scanning | |CodeQL| |br| | -| | |ESLint| |br| | -| | |RustClippy| | -+-------------------------------------------+---------------+ + ++------------+---------------------+--------+-------------------+ +| Language | Version | Solved | Status | ++============+=====================+========+===================+ +| C | C99+ in: ``gcc``, | 17 | |Ci| | +| | |br| ``clang``, | | | +| | ``msvc``, |br| | | | +| | ``pcc``, ``tcc`` | | | ++------------+---------------------+--------+-------------------+ +| C++ | C++98+ in ``g++`` | 1 | |Cpi| | +| | |br| ``clang``, | | | +| | ``msvc`` | | | ++------------+---------------------+--------+-------------------+ +| C# | .NET 2+ | 6 | |C#i| | ++------------+---------------------+--------+-------------------+ +| JavaScript | Node 12+ | 5 | |JavaScript| | ++------------+---------------------+--------+-------------------+ +| Python | CPython 3.6+ |br| | 70 | |Python| | +| | Pypy 3.6+ |br| | | | +| | GraalPy 23.1+ | | | ++------------+---------------------+--------+-------------------+ +| Rust | 1.69+ | 10 | |Rust| | ++------------+---------------------+--------+-------------------+ +| Documentation (in progress) | |Pages| | ++-------------------------------------------+-------------------+ +| Code Coverage | |Coverage| | ++-------------------------------------------+-------------------+ +| Code Scanning | |CodeQL| |br| | +| | |ESLint| |br| | +| | |PythonLint| |br| | +| | |RustClippy| | ++-------------------------------------------+-------------------+ Coverage -------- diff --git a/cplusplus/README.rst b/cplusplus/README.rst new file mode 100644 index 00000000..b844f0f5 --- /dev/null +++ b/cplusplus/README.rst @@ -0,0 +1,158 @@ +C++ Section +=========== + +.. |C++ Check| image:: https://github.com/LivInTheLookingGlass/Euler/actions/workflows/cplusplus.yml/badge.svg + :target: https://github.com/LivInTheLookingGlass/Euler/actions/workflows/cplusplus.yml + +|C++ Check| + +All problems are solved in C++98. It is tested on clang, g++, 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 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 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. + +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.cpp>`__ + diff --git a/csharp/README.rst b/csharp/README.rst index 3b042ba5..cbd85897 100644 --- a/csharp/README.rst +++ b/csharp/README.rst @@ -77,3 +77,9 @@ Problems Solved --------------- - ☒ `1 <./p0001.cs>`__ +- ☒ `2 <./p0002.cs>`__ +- ☒ `4 <./p0004.cs>`__ +- ☒ `6 <./p0006.cs>`__ +- ☒ `8 <./p0008.cs>`__ +- ☒ `9 <./p0009.cs>`__ + diff --git a/docs/index.rst b/docs/index.rst index 7cfb09de..ee1f96e5 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -91,7 +91,7 @@ This project is divided into several Makefiles, connected by a root Makefile whi +-----------+------+------+------+------+------+------+ | | |C| | |Cp| | |C#| | |Js| | |Py| | |Rs| | +===========+======+======+======+======+======+======+ -|Coverage | |d| | |d| | |d| | |d| | |d| | |d| | +|Coverage | |d| | |ip| | |d| | |d| | |d| | |d| | +-----------+------+------+------+------+------+------+ |Docs | |ip| | |ip| | |d| | |d| | |d| | |d| | +-----------+------+------+------+------+------+------+ diff --git a/javascript/README.rst b/javascript/README.rst index b621546d..050898a0 100644 --- a/javascript/README.rst +++ b/javascript/README.rst @@ -76,3 +76,6 @@ Problems Solved - ☒ `1 <./p0001.js>`__ - ☒ `2 <./p0002.js>`__ +- ☒ `6 <./p0002.js>`__ +- ☒ `8 <./p0002.js>`__ +- ☒ `9 <./p0002.js>`__ diff --git a/rust/README.rst b/rust/README.rst index 22fd4400..d67e8764 100644 --- a/rust/README.rst +++ b/rust/README.rst @@ -58,5 +58,14 @@ dependencies for this section. Problems Solved --------------- -- ☒ `1 <./p0001.rs>`__ +- ☒ `1 <./src/p0001.rs>`__ +- ☒ `2 <./src/p0002.rs>`__ +- ☒ `3 <./src/p0003.rs>`__ +- ☒ `4 <./src/p0004.rs>`__ +- ☒ `5 <./src/p0005.rs>`__ +- ☒ `6 <./src/p0006.rs>`__ +- ☒ `7 <./src/p0007.rs>`__ +- ☒ `8 <./src/p0008.rs>`__ +- ☒ `9 <./src/p0009.rs>`__ +- ☒ `10 <./src/p0010.rs>`__