* Add digital root algorithm
* refactor: use descriptive parameter name `number` instead of `n` (algorithms-keeper)
Also see: project_euler/problem_092/sol1.py
* Update pi monte carlo script to run tests with fixed seed.
* updating DIRECTORY.md
* Update pi_monte_carlo_estimation.py
* Import pi from math module
---------
Co-authored-by: Christian Clauss <cclauss@me.com>
Co-authored-by: cclauss <cclauss@users.noreply.github.com>
Closes the remaining items in #13171: friendly ValueError for non-numeric
inputs (str/dict) instead of raw numpy messages, optional axis=None for a
whole-array distribution, documented NaN/inf behavior, and doctests covering
identical logits, large (overflow-prone) logits, 2-D axis selection, empty
input, non-numeric input, and out-of-bounds axis.
Importing maths.matrix_exponentiation raised 'NameError: name Matrix is
not defined' because __mul__ and modular_exponentiation annotate with
Matrix before the class name is bound (annotations evaluate eagerly at
class-body execution time).
Add 'from __future__ import annotations' to defer annotation evaluation,
matching the pattern used elsewhere in the repo.
Verified on current master: import succeeds (NameError gone) and all 10
doctests pass.
Signed-off-by: sudo-ai-git <sudo-ai-git@users.noreply.github.com>
Co-authored-by: sudo-ai-git <sudo-ai-git@users.noreply.github.com>
* feat: add numerical laplace transform
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Update maths/laplace_transformation.py
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* refactor: add input validation and fix doctest precision
* fix: address PR review comments
Updated module docstring, added validation for non-negative s_value, and replaced arrange with linspace for clarity.
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Refactor docstring and remove unnecessary blank lines
Removed extra blank lines and cleaned up docstring.
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Refactor error handling for s_value check
* Fix indentation for s_value validation
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* Add Sieve of Atkin algorithm for efficient prime generation
Implement the Sieve of Atkin algorithm as an alternative to the existing
Sieve of Eratosthenes. This modern algorithm offers better theoretical
complexity O(n / log log n) and uses quadratic forms for prime detection.
Features:
- Comprehensive docstring with algorithm explanation
- Type hints and input validation
- Extensive doctests covering edge cases
- Follows repository coding conventions
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Fix: add missing newline at end of file
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Delete pr_description.txt
* Enhance documentation for Sieve of Atkin
Added additional explanation about the Sieve of Atkin algorithm.
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
* Add Brent's Method for root finding (numerical analysis)
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Fix parameter names and lint issues in Brent's Method
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Fix import name
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Rename maths/brent_method.py to maths/numerical_analysis/brent_method.py
---------
Co-authored-by: debesh <debeshmaheshwari008@gmail.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
* Add Tonelli-Shanks modular square root algorithm.
Implements Legendre symbol checks and both the p≡3 (mod 4) fast path and
the full Tonelli-Shanks procedure, with doctests for success and error cases.
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Fix ruff EM102 by assigning exception messages before raise.
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* Add improved doctrings and doctests for math/perfect_number.py
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
* Create logarithmic_series.py
This is an implementation of logarithmic series in Python.
Reference: https://math.stackexchange.com/questions/3973429/what-is-a-logarithmic-series
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Update logarithmic_series.py
Fixed long line issue
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Update logarithmic_series.py
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* updating DIRECTORY.md
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
Co-authored-by: cclauss <cclauss@users.noreply.github.com>
* Add doctests for sum_of_arithmetic_series function
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
* Added Trailing Zero Algo
Created an algorithm that return the trailing zeroes of a number
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* updating DIRECTORY.md
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
Co-authored-by: cclauss <cclauss@users.noreply.github.com>
* feat: add Matrix Exponentiation method
docs: updated the header documentation and added new documentation for
the new function.
* feat: added new function matrix exponetiation method
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* feat: This function uses the tail-recursive form of the Euclidean algorithm to calculate
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* reduced the number of characters per line in the comments
* removed unwanted code
* feat: Implemented a new function to swaap numbers without dummy variable
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* removed previos code
* Done with the required changes
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Done with the required changes
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Done with the required changes
* Done with the required changes
* Done with the required changes
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Update maths/fibonacci.py
Co-authored-by: Tianyi Zheng <tianyizheng02@gmail.com>
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Done with the required changes
* Done with the required changes
* Done with the required changes
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* feat(timing): enhance timing function with adaptive units and run averaging
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* feat(timing): enhance timing function with adaptive units and run averaging
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Tianyi Zheng <tianyizheng02@gmail.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
* Add files via upload
An algorithm to find intersection between 2 lines.
* Added doctest to function
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* fixed ruff issues
* updating DIRECTORY.md
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
Co-authored-by: cclauss <cclauss@users.noreply.github.com>
* weddle's integration rule
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* checks passed
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* added return type hint
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Added type hints to function parameters and return types
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* added descriptive names
* safe eval used
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* changed parameter hint
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* updated function signatures, type hints, and docstrings; modified function implementations and variable names.
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* changes made in doctest
* updating DIRECTORY.md
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
Co-authored-by: cclauss <cclauss@users.noreply.github.com>
* Added function that calculates Pell numbers
* Fixed ruff error
* Renamed input argument to be more descriptive
* updating DIRECTORY.md
---------
Co-authored-by: Christian Clauss <cclauss@me.com>
Co-authored-by: cclauss <cclauss@users.noreply.github.com>
* maths: add weighted_average function
* style: fix blank line after imports
* maths: simplify empty input check in weighted_average
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Delete maths/average_weighted.py
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
* Update softmax.py
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Update softmax.py
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* fix: sub-interval midpoint formula in ternary search
* fix(maths): resolve NameError on self-referential class type annotations in matrix_exponentiation.py
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* fix(maths): remove unnecessary future annotations import
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* Update area.py
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Update area.py
Added functions for cone and cylinder lateral surface areas
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* refactor: remove unnecessary empty iterable in deque (RUF037)
Clean up trailing whitespace and empty list in deque initialization to satisfy Ruff linting rules.
* style: update jump_search to use PEP 695 type parameters
Updated the jump_search function signature to use the Python 3.12+ generic type parameter syntax [T]. This resolves the UP047 linting error flagged by Ruff.
* style: update valid_input to use Python 3.12 type parameters
Applied PEP 695 syntax to the valid_input function by moving the 'num' generic into brackets. This resolves the UP047 error in the machine_learning directory.
* fix(types): add Comparable bound to jump_search type parameter
Updated the PEP 695 type parameter syntax to include the 'Comparable' bound. This resolves the Mypy error regarding unsupported left operand types for the '<' operator, ensuring that the generic type T supports comparisons.
* Extra empty space removal
Removed an extra empty line at the end of the file.
* Update area.py
Added a function to calculate the surface area of a regular prism
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Update area.py
Corrected line length
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Apply batched suggestions from code review
Co-authored-by: Christian Clauss <cclauss@me.com>
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
* Update volume.py
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* refactor: remove unnecessary empty iterable in deque (RUF037)
Clean up trailing whitespace and empty list in deque initialization to satisfy Ruff linting rules.
* style: update valid_input to use Python 3.12 type parameters
Applied PEP 695 syntax to the valid_input function by moving the 'num' generic into brackets. This resolves the UP047 error in the machine_learning directory.
* style: update generic functions to Python 3.12 syntax (UP047)
Refactor jump_search to use PEP 695 type parameters [T] as required by the latest Ruff configuration.
* fix(types): add Comparable bound to jump_search type parameter
Updated the PEP 695 type parameter syntax to include the 'Comparable' bound. This resolves the Mypy error regarding unsupported left operand types for the '<' operator, ensuring that the generic type T supports comparisons.
* Apply batched suggestions from code review
Co-authored-by: Christian Clauss <cclauss@me.com>
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
2026-09-06 00:04:35 +02:00
Michael HauseggerTheRealHauiChristian Clausspre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>pre-commit-ci[bot] <pre-commit-ci[bot]@users.noreply.github.com>
* Added some Unit Tests to increase test code coverage
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* updating DIRECTORY.md
---------
Co-authored-by: TheRealHaui <michael.hausegger@hausegger.tech>
Co-authored-by: Christian Clauss <cclauss@me.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <pre-commit-ci[bot]@users.noreply.github.com>
* deps: migrate from httpx to httpx2 (pydantic's maintained fork)
Mechanical rename of httpx -> httpx2 (API-compatible fork of httpx 0.28.1):
pyproject.toml deps, PEP 723 inline-script headers, and all import/call sites.
Excludes uv.lock (the keeper's allow-list rejects .lock files); the lock
refresh needs a separate maintainer-merged PR.
Refs #15081
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* deps: drop tweepy + migrate remaining requests refs to httpx2
- maths/allocation_number.py: docstring example uses httpx2, not requests
- web_programming/get_imdbtop.py.DISABLED: import httpx2 instead of requests
- remove web_programming/get_user_tweets.py.DISABLED (a Twitter API how-to,
not an algorithm) and drop the tweepy dependency that was its only user and
the last high-level dep pulling in requests
- uv.lock intentionally untouched (keeper allow-list)
Refs #15081
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* Create recursions
* Delete recursions
* Create ...
* Create recursive_digit_sum.py
* Update recursive_digit_sum.py
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Update recursive_digit_sum.py
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Update recursive_digit_sum.py
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Update recursive_digit_sum.py
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Create __init__.py
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Update recursive_digit_sum.py
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Delete recursions/...
* Delete recursions/__init__.py
* Clarify parameter descriptions in super_digit function
Updated docstring to clarify parameter descriptions.
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
The docstring incorrectly referenced Sylvester's sequence (a copy-paste
error from maths/sylvester_sequence.py) and used param names that did
not match the actual function signature.
Fixes#15013
Co-authored-by: kumarsatyam9378-art <kumarsatyam9378@gmail.com>
* Fix doctests in factorial_recursive function
The doctests in factorial_recursive were calling factorial() instead of factorial_recursive(). This fix ensures that the tests correctly validate the factorial_recursive function itself.
* Update factorial.py
---------
Co-authored-by: Maxim Smolskiy <mithridatus@mail.ru>
* Fix incorrect doctest references in fibonacci functions
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Maxim Smolskiy <mithridatus@mail.ru>
* Improve documentation for linear search algorithm
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Replace asserts with explicit validation in modular_division
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Update linear_search.py
---------
Co-authored-by: Anusha-DeviE <itzanushadevi@gmail.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Maxim Smolskiy <mithridatus@mail.ru>
* Use TypeError for non-string input in count_vowels
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Fix docstring and improve input validation in kth_lexicographic_permutation
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Handle gcd(0, 0) edge case
* Update kth_lexicographic_permutation.py
* Update count_vowels.py
* Update greatest_common_divisor.py
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Maxim Smolskiy <mithridatus@mail.ru>
- Add -> None return type annotation to pi_estimator function
- Improves code clarity and follows Python type hinting best practices
- Function already had proper type hints for parameters
Co-authored-by: Gunish Mukherji <gunishmukherji@Gunishs-MacBook-Air.local>
Co-authored-by: Maxim Smolskiy <mithridatus@mail.ru>
* Fix typo in spheres intersection print statement
* Fix typo in CONTRIBUTING.md
* Improve comments in comb_sort.py
* pyproject.toml: tool.ruff.target-version = "py314"
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Fix comment formatting in lint.ignore section
---------
Co-authored-by: Christian Clauss <cclauss@me.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* pre-commit autoupdate 2025-09-11
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* Adding the function isProthNumber(n : int) which returns true if n is a Proth number
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Fixing the issues of the isprothnumber function
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* New fixes on isprothnumber()
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Fixes on isprothnumber()
* Fixes on isprothnumber
* Fixes on isprothnumber()
* Fixes on isprothnumber
* Update proth_number.py
* Update proth_number.py
* Update proth_number.py
* Update proth_number.py
* Update proth_number.py
* Update proth_number.py
* Update proth_number.py
* Update proth_number.py
---------
Co-authored-by: Juanitoupipou <juan.dupierris@imt-atlantique.net>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Maxim Smolskiy <mithridatus@mail.ru>
* Add weierstrass_method for approximating complex roots
- Implements Durand-Kerner (Weierstrass) method for polynomial root finding
- Accepts user-defined polynomial function and degree
- Uses random perturbation of complex roots of unity for initial guesses
- Handles validation, overflow clipping, and includes doctest
* Update weierstrass_method.py
* add more tests
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Update weierstrass_method.py
* Update weierstrass_method.py
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>