Skip to content

Commit

Permalink
Begin moving helper functions into library
Browse files Browse the repository at this point in the history
  • Loading branch information
LivInTheLookingGlass committed Jul 26, 2024
1 parent 90fe5bf commit 7de2b8b
Show file tree
Hide file tree
Showing 57 changed files with 412 additions and 193 deletions.
2 changes: 1 addition & 1 deletion c/test_euler.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ def test_compiler_macros(compiler):

@mark.skipif('NO_OPTIONAL_TESTS or ONLY_SLOW')
def test_is_prime(benchmark, compiler):
from p0007 import is_prime, prime_factors, primes
from lib.primes import is_prime, prime_factors, primes
MAX_PRIME = 1_000_000
exename = EXE_TEMPLATE.format("test_is_prime", compiler)
test_path = C_FOLDER.joinpath("tests", "test_is_prime.c")
Expand Down
2 changes: 1 addition & 1 deletion cplusplus/test_euler.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ def test_compiler_macros(compiler):

# @mark.skipif('NO_OPTIONAL_TESTS or ONLY_SLOW')
# def test_is_prime(benchmark, compiler):
# from p0007 import is_prime, prime_factors, primes
# from lib.primes import is_prime, prime_factors, primes
# MAX_PRIME = 1_000_000
# exename = EXE_TEMPLATE.format("test_is_prime", compiler)
# test_path = CPP_FOLDER.joinpath("tests", "test_is_prime.cpp")
Expand Down
10 changes: 10 additions & 0 deletions docs/python.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,16 @@ Euler Python Implementation
:start-line: 2
:end-before: Problems Solved

Library Code
------------

.. toctree::
:glob:
:numbered:
:maxdepth: 1

python/primes

Problems Solved
---------------

Expand Down
13 changes: 13 additions & 0 deletions docs/python/fibonacci.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
fibonacci.py
============

View source code `here on GitHub! <https://github.com/LivInTheLookingGlass/Euler/blob/master/python/lib/fibonacci.py>`_

.. automodule:: python.lib.fibonacci
:members:
:undoc-members:

.. literalinclude:: ../../python/lib/fibonacci.py
:language: python
:linenos:

8 changes: 8 additions & 0 deletions docs/python/p0003.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@ Python Implementation of Problem 3

View source code `here on GitHub! <https://github.com/LivInTheLookingGlass/Euler/blob/master/python/p0003.py>`_

Includes
--------

- `primes <./primes.html>`_

Problem Solution
----------------

.. automodule:: python.p0003
:members:
:undoc-members:
Expand Down
8 changes: 8 additions & 0 deletions docs/python/p0007.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@ Python Implementation of Problem 7

View source code `here on GitHub! <https://github.com/LivInTheLookingGlass/Euler/blob/master/python/p0007.py>`_

Includes
--------

- `primes <./primes.html>`_

Problem Solution
----------------

.. automodule:: python.p0007
:members:
:undoc-members:
Expand Down
8 changes: 8 additions & 0 deletions docs/python/p0010.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@ Python Implementation of Problem 10

View source code `here on GitHub! <https://github.com/LivInTheLookingGlass/Euler/blob/master/python/p0010.py>`_

Includes
--------

- `primes <./primes.html>`_

Problem Solution
----------------

.. automodule:: python.p0010
:members:
:undoc-members:
Expand Down
8 changes: 8 additions & 0 deletions docs/python/p0021.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@ Python Implementation of Problem 21

View source code `here on GitHub! <https://github.com/LivInTheLookingGlass/Euler/blob/master/python/p0021.py>`_

Includes
--------

- `primes <./primes.html>`_

Problem Solution
----------------

.. automodule:: python.p0021
:members:
:undoc-members:
Expand Down
8 changes: 8 additions & 0 deletions docs/python/p0027.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@ Python Implementation of Problem 27

View source code `here on GitHub! <https://github.com/LivInTheLookingGlass/Euler/blob/master/python/p0027.py>`_

Includes
--------

- `primes <./primes.html>`_

Problem Solution
----------------

.. automodule:: python.p0027
:members:
:undoc-members:
Expand Down
8 changes: 8 additions & 0 deletions docs/python/p0035.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@ Python Implementation of Problem 35

View source code `here on GitHub! <https://github.com/LivInTheLookingGlass/Euler/blob/master/python/p0035.py>`_

Includes
--------

- `primes <./primes.html>`_

Problem Solution
----------------

.. automodule:: python.p0035
:members:
:undoc-members:
Expand Down
8 changes: 8 additions & 0 deletions docs/python/p0037.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@ Python Implementation of Problem 37

View source code `here on GitHub! <https://github.com/LivInTheLookingGlass/Euler/blob/master/python/p0037.py>`_

Includes
--------

- `primes <./primes.html>`_

Problem Solution
----------------

.. automodule:: python.p0037
:members:
:undoc-members:
Expand Down
8 changes: 8 additions & 0 deletions docs/python/p0041.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@ Python Implementation of Problem 41

View source code `here on GitHub! <https://github.com/LivInTheLookingGlass/Euler/blob/master/python/p0041.py>`_

Includes
--------

- `primes <./primes.html>`_

Problem Solution
----------------

.. automodule:: python.p0041
:members:
:undoc-members:
Expand Down
8 changes: 8 additions & 0 deletions docs/python/p0046.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@ Python Implementation of Problem 46

View source code `here on GitHub! <https://github.com/LivInTheLookingGlass/Euler/blob/master/python/p0046.py>`_

Includes
--------

- `primes <./primes.html>`_

Problem Solution
----------------

.. automodule:: python.p0046
:members:
:undoc-members:
Expand Down
8 changes: 8 additions & 0 deletions docs/python/p0047.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@ Python Implementation of Problem 47

View source code `here on GitHub! <https://github.com/LivInTheLookingGlass/Euler/blob/master/python/p0047.py>`_

Includes
--------

- `primes <./primes.html>`_

Problem Solution
----------------

.. automodule:: python.p0047
:members:
:undoc-members:
Expand Down
8 changes: 8 additions & 0 deletions docs/python/p0049.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@ Python Implementation of Problem 49

View source code `here on GitHub! <https://github.com/LivInTheLookingGlass/Euler/blob/master/python/p0049.py>`_

Includes
--------

- `primes <./primes.html>`_

Problem Solution
----------------

.. automodule:: python.p0049
:members:
:undoc-members:
Expand Down
8 changes: 8 additions & 0 deletions docs/python/p0050.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@ Python Implementation of Problem 50

View source code `here on GitHub! <https://github.com/LivInTheLookingGlass/Euler/blob/master/python/p0050.py>`_

Includes
--------

- `primes <./primes.html>`_

Problem Solution
----------------

.. automodule:: python.p0050
:members:
:undoc-members:
Expand Down
8 changes: 8 additions & 0 deletions docs/python/p0058.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@ Python Implementation of Problem 58

View source code `here on GitHub! <https://github.com/LivInTheLookingGlass/Euler/blob/master/python/p0058.py>`_

Includes
--------

- `primes <./primes.html>`_

Problem Solution
----------------

.. automodule:: python.p0058
:members:
:undoc-members:
Expand Down
8 changes: 8 additions & 0 deletions docs/python/p0060.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@ Python Implementation of Problem 60

View source code `here on GitHub! <https://github.com/LivInTheLookingGlass/Euler/blob/master/python/p0060.py>`_

Includes
--------

- `primes <./primes.html>`_

Problem Solution
----------------

.. automodule:: python.p0060
:members:
:undoc-members:
Expand Down
8 changes: 8 additions & 0 deletions docs/python/p0069.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@ Python Implementation of Problem 69

View source code `here on GitHub! <https://github.com/LivInTheLookingGlass/Euler/blob/master/python/p0069.py>`_

Includes
--------

- `primes <./primes.html>`_

Problem Solution
----------------

.. automodule:: python.p0069
:members:
:undoc-members:
Expand Down
8 changes: 8 additions & 0 deletions docs/python/p0077.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@ Python Implementation of Problem 77

View source code `here on GitHub! <https://github.com/LivInTheLookingGlass/Euler/blob/master/python/p0077.py>`_

Includes
--------

- `primes <./primes.html>`_

Problem Solution
----------------

.. automodule:: python.p0077
:members:
:undoc-members:
Expand Down
8 changes: 8 additions & 0 deletions docs/python/p0087.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@ Python Implementation of Problem 87

View source code `here on GitHub! <https://github.com/LivInTheLookingGlass/Euler/blob/master/python/p0087.py>`_

Includes
--------

- `primes <./primes.html>`_

Problem Solution
----------------

.. automodule:: python.p0087
:members:
:undoc-members:
Expand Down
8 changes: 8 additions & 0 deletions docs/python/p0118.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@ Python Implementation of Problem 118

View source code `here on GitHub! <https://github.com/LivInTheLookingGlass/Euler/blob/master/python/p0118.py>`_

Includes
--------

- `primes <./primes.html>`_

Problem Solution
----------------

.. automodule:: python.p0118
:members:
:undoc-members:
Expand Down
8 changes: 8 additions & 0 deletions docs/python/p0123.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@ Python Implementation of Problem 123

View source code `here on GitHub! <https://github.com/LivInTheLookingGlass/Euler/blob/master/python/p0123.py>`_

Includes
--------

- `primes <./primes.html>`_

Problem Solution
----------------

.. automodule:: python.p0123
:members:
:undoc-members:
Expand Down
8 changes: 8 additions & 0 deletions docs/python/p0134.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@ Python Implementation of Problem 134

View source code `here on GitHub! <https://github.com/LivInTheLookingGlass/Euler/blob/master/python/p0134.py>`_

Includes
--------

- `primes <./primes.html>`_

Problem Solution
----------------

.. automodule:: python.p0134
:members:
:undoc-members:
Expand Down
8 changes: 8 additions & 0 deletions docs/python/p0187.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@ Python Implementation of Problem 187

View source code `here on GitHub! <https://github.com/LivInTheLookingGlass/Euler/blob/master/python/p0187.py>`_

Includes
--------

- `primes <./primes.html>`_

Problem Solution
----------------

.. automodule:: python.p0187
:members:
:undoc-members:
Expand Down
8 changes: 8 additions & 0 deletions docs/python/p0357.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@ Python Implementation of Problem 357

View source code `here on GitHub! <https://github.com/LivInTheLookingGlass/Euler/blob/master/python/p0357.py>`_

Includes
--------

- `primes <./primes.html>`_

Problem Solution
----------------

.. automodule:: python.p0357
:members:
:undoc-members:
Expand Down
13 changes: 13 additions & 0 deletions docs/python/primes.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
primes.py
=========

View source code `here on GitHub! <https://github.com/LivInTheLookingGlass/Euler/blob/master/python/lib/primes.py>`_

.. automodule:: python.lib.primes
:members:
:undoc-members:

.. literalinclude:: ../../python/lib/primes.py
:language: python
:linenos:

Loading

0 comments on commit 7de2b8b

Please sign in to comment.