Skip to content

Commit

Permalink
Significant work on docs
Browse files Browse the repository at this point in the history
  • Loading branch information
LivInTheLookingGlass committed Jul 21, 2024
1 parent afddd2f commit ecf8abb
Show file tree
Hide file tree
Showing 27 changed files with 265 additions and 25 deletions.
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
c/*.c linguist-language=c
c/*.h linguist-language=c
cplusplus/*.cpp linguist-language=c++
cplusplus/*.h linguist-language=c++
10 changes: 7 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
**.pyc
__pycache__/**
**/__pycache__/**
**/.pytest_cache/**
**/.mypy_cache/**
javascript/node_modules/**
.pytest_cache/**
.mypy_cache/**
**/node_modules/**
.vscode/**
**log*.txt
**/a.out
**/*.exe
**/build/**
venv/**
**/venv/**
**.dll
**.pdb
csharp/*/obj
Expand All @@ -17,4 +21,4 @@ docs/_build
rust/target
**/.coverage
**/.coverage.*
javascript/coverage
**/coverage
4 changes: 4 additions & 0 deletions cplusplus/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ around that. This test checks that those macros are correct.
Prime Infrastructure Test
~~~~~~~~~~~~~~~~~~~~~~~~~

(Note that this is in progress, and these tests will be run only when
there is an implementation to refer to. Since they are identical to the
test in the c folder, the test is already written and ready to go.)

This test checks five things:

1. It checks ``is_prime()`` for numbers up to ``MAX_PRIME``, where that
Expand Down
14 changes: 7 additions & 7 deletions docs/c/bcd.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,18 @@ It was also a good exercise in x86 assembly, as several portions are accellerate
Shortcut value to determine if the encoded integer is 0.

.. c:function:: void free_BCD_int(BCD_int x)
.. c:function:: void free_BCD_int(BCD_int x)
.. c:function:: BCD_int new_BCD_int(uintmax_t a, bool negative)
.. c:function:: BCD_int new_BCD_int(uintmax_t a, bool negative)
.. c:function:: BCD_int BCD_from_bytes(const unsigned char *str, size_t chars, bool negative, bool little_endian)
.. c:function:: BCD_int BCD_from_bytes(const unsigned char *str, size_t chars, bool negative, bool little_endian)
Takes in an arbitrary-sized encoded integer (like in Python's :external:py:meth:`int.from_bytes`) to a
:c:type:`BCD_int`.
Takes in an arbitrary-sized encoded integer (like in Python's :external:py:meth:`int.from_bytes`) to a
:c:type:`BCD_int`.
.. c:function:: BCD_int BCD_from_ascii(const char *str, size_t digits, bool negative)
.. c:function:: BCD_int BCD_from_ascii(const char *str, size_t digits, bool negative)
From an ASCII-encoded integer to a :c:ref:`BCD_int`.
From an ASCII-encoded integer to a :c:ref:`BCD_int`.
.. c:function:: BCD_int add_bcd(BCD_int x, BCD_int y)
Expand Down
4 changes: 2 additions & 2 deletions docs/c/factors.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ factors for a given number. It is generally used by first calling
.. c:function:: uintmax_t advance_factor_counter(factor_counter *fc)
.. c:function:: factor_counter proper_divisors(uintmax_t target)
.. c:function:: factor_counter proper_divisors(uintmax_t target)
.. c:function:: uintmax_t proper_divisor_count(uintmax_t target)
.. c:function:: uintmax_t proper_divisor_count(uintmax_t target)
.. c:namespace-pop::
4 changes: 2 additions & 2 deletions docs/c/fibonacci.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ fibonacci.h
This represents the largest number the iterator is allowed to yield.

.. c:function:: fibonacci fibonacci1(uintmax_t limit)
.. c:function:: fibonacci fibonacci1(uintmax_t limit)
.. c:function:: fibonacci fibonacci0()
.. c:function:: fibonacci fibonacci0()
.. c:namespace-pop::
22 changes: 18 additions & 4 deletions docs/c/iterator.rst
Original file line number Diff line number Diff line change
Expand Up @@ -64,24 +64,38 @@ iterator.h
.. c:member:: uintmax_t (*iterator_function)(counter *it)
The function to advance the iterator and return the next element.
.. c:member:: bool exhausted : 1
An indicator that tells you if the iterator is exhausted.
.. c:member:: bool started : 1
An indicator that tells you if the interator has moved at all.
.. c:member:: bool phase : 1
An indicator that flips every time the iterator moves.
.. c:member:: uintmax_t idx
The current position of the counter.
.. c:member:: uintmax_t stop
The point before which the counter will stop (as in :external:py:ref:`range`).
.. c:member:: intmax_t step
.. c:function:: uintmax_t iterate_counter(counter *i)
The amount by which the counter will move in each iteration (as in :external:py:ref:`range`).
.. c:function:: uintmax_t iterate_counter(counter *i)
.. c:function:: counter counter3(uintmax_t start, uintmax_t stop, intmax_t step)
.. c:function:: counter counter3(uintmax_t start, uintmax_t stop, intmax_t step)
.. c:function:: counter counter2(uintmax_t start, uintmax_t stop)
.. c:function:: counter counter2(uintmax_t start, uintmax_t stop)
.. c:function:: counter counter1(uintmax_t stop)
.. c:function:: counter counter1(uintmax_t stop)
.. c:namespace-pop::
12 changes: 12 additions & 0 deletions docs/c/p0001.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,18 @@ Includes

- `iterator.h <./iterator.html>`__

Solution
--------

.. c:func:: unsigned long long p0001()
.. c:func:: int main(int argc, char const *argv[])
.. note::
This function is only present in the Python test runner, or when compiling as a standalone program.
It is not present when compiling for the Unity test runner.
.. literalinclude:: ../../c/p0001.c
:language: C
:linenos:
12 changes: 12 additions & 0 deletions docs/c/p0002.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,18 @@ Includes

- `fibonacci.h <./fibonacci.html>`__

Solution
--------

.. c:func:: unsigned long long p0002()
.. c:func:: int main(int argc, char const *argv[])
.. note::
This function is only present in the Python test runner, or when compiling as a standalone program.
It is not present when compiling for the Unity test runner.
.. literalinclude:: ../../c/p0002.c
:language: C
:linenos:
12 changes: 12 additions & 0 deletions docs/c/p0003.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,18 @@ Includes

- `primes.h <./primes.html>`__

Solution
--------

.. c:func:: unsigned long long p0003()
.. c:func:: int main(int argc, char const *argv[])
.. note::
This function is only present in the Python test runner, or when compiling as a standalone program.
It is not present when compiling for the Unity test runner.
.. literalinclude:: ../../c/p0003.c
:language: C
:linenos:
12 changes: 12 additions & 0 deletions docs/c/p0004.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,18 @@ Includes

- `iterator.h <./digits.html>`__

Solution
--------

.. c:func:: unsigned long long p0004()
.. c:func:: int main(int argc, char const *argv[])
.. note::
This function is only present in the Python test runner, or when compiling as a standalone program.
It is not present when compiling for the Unity test runner.
.. literalinclude:: ../../c/p0004.c
:language: C
:linenos:
12 changes: 12 additions & 0 deletions docs/c/p0005.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,18 @@ Includes
- `macros.h <./macros.html>`__
- `primes.h <./primes.html>`__

Solution
--------

.. c:func:: unsigned long long p0005()
.. c:func:: int main(int argc, char const *argv[])
.. note::
This function is only present in the Python test runner, or when compiling as a standalone program.
It is not present when compiling for the Unity test runner.
.. literalinclude:: ../../c/p0005.c
:language: C
:linenos:
12 changes: 12 additions & 0 deletions docs/c/p0006.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,18 @@ C Implementation of Problem 6

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

Solution
--------

.. c:func:: unsigned long long p0006()
.. c:func:: int main(int argc, char const *argv[])
.. note::
This function is only present in the Python test runner, or when compiling as a standalone program.
It is not present when compiling for the Unity test runner.
.. literalinclude:: ../../c/p0006.c
:language: C
:linenos:
12 changes: 12 additions & 0 deletions docs/c/p0007.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,18 @@ Includes

- `primes.h <./primes.html>`__

Solution
--------

.. c:func:: unsigned long long p0007()
.. c:func:: int main(int argc, char const *argv[])
.. note::
This function is only present in the Python test runner, or when compiling as a standalone program.
It is not present when compiling for the Unity test runner.
.. literalinclude:: ../../c/p0007.c
:language: C
:linenos:
12 changes: 12 additions & 0 deletions docs/c/p0008.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,18 @@ Includes

- `macros.h <./macros.html>`__

Solution
--------

.. c:func:: unsigned long long p0008()
.. c:func:: int main(int argc, char const *argv[])
.. note::
This function is only present in the Python test runner, or when compiling as a standalone program.
It is not present when compiling for the Unity test runner.
.. literalinclude:: ../../c/p0008.c
:language: C
:linenos:
12 changes: 12 additions & 0 deletions docs/c/p0009.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,18 @@ C Implementation of Problem 9

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

Solution
--------

.. c:func:: unsigned long long p0009()
.. c:func:: int main(int argc, char const *argv[])
.. note::
This function is only present in the Python test runner, or when compiling as a standalone program.
It is not present when compiling for the Unity test runner.
.. literalinclude:: ../../c/p0009.c
:language: C
:linenos:
12 changes: 12 additions & 0 deletions docs/c/p0010.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,18 @@ Includes

- `primes.h <./primes.html>`__

Solution
--------

.. c:func:: unsigned long long p0010()
.. c:func:: int main(int argc, char const *argv[])
.. note::
This function is only present in the Python test runner, or when compiling as a standalone program.
It is not present when compiling for the Unity test runner.
.. literalinclude:: ../../c/p0010.c
:language: C
:linenos:
12 changes: 12 additions & 0 deletions docs/c/p0011.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,18 @@ Includes

- `macros.h <./macros.html>`__

Solution
--------

.. c:func:: unsigned long long p0011()
.. c:func:: int main(int argc, char const *argv[])
.. note::
This function is only present in the Python test runner, or when compiling as a standalone program.
It is not present when compiling for the Unity test runner.
.. literalinclude:: ../../c/p0011.c
:language: C
:linenos:
16 changes: 14 additions & 2 deletions docs/c/p0012.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,26 @@ C Implementation of Problem 12 (port in progress)

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

.. note::

The port of this problem is still in progress

Includes
--------

- `macros.h <./macros.html>`__

.. note::
Solution
--------

The port of this problem is still in progress
.. c:func:: unsigned long long p0012()
.. c:func:: int main(int argc, char const *argv[])
.. note::
This function is only present in the Python test runner, or when compiling as a standalone program.
It is not present when compiling for the Unity test runner.
.. literalinclude:: ../../c/p0012.c
:language: C
Expand Down
12 changes: 12 additions & 0 deletions docs/c/p0013.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,18 @@ Includes

- `bcd.h <./bcd.html>`__

Solution
--------

.. c:func:: unsigned long long p0013()
.. c:func:: int main(int argc, char const *argv[])
.. note::
This function is only present in the Python test runner, or when compiling as a standalone program.
It is not present when compiling for the Unity test runner.
.. literalinclude:: ../../c/p0013.c
:language: C
:linenos:
Loading

0 comments on commit ecf8abb

Please sign in to comment.