Commit Graph
519 Commits
Author SHA1 Message Date
Nefelibata be65e47b54 Add Digital Root algorithm to maths (#14988)
* Add digital root algorithm

* refactor: use descriptive parameter name `number` instead of `n` (algorithms-keeper)

Also see: project_euler/problem_092/sol1.py
2026-09-13 13:38:39 +02:00
78255cb1c7 Update pi monte carlo script to run tests with fixed seed. (#12757)
* 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>
2026-09-13 10:22:38 +02:00
priya-sundaram-dev 9cd7ee0c59 maths/softmax: clear errors for non-numeric input, axis=None, edge-case doctests (#15312)
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.
2026-09-13 10:00:19 +02:00
Christian Clauss 0525ef5da8 ruff rule ANN202 missing-return-type-private-function (#15298)
* ruff rule ANN202 missing-return-type-private-function

* ruff rule ANN202 missing-return-type-private-function
2026-09-12 21:47:08 +02:00
Christian Clauss 0da45b148a ruff rule ANN204 missing-return-type-special-method (#15300) 2026-09-12 21:35:04 +02:00
Christian Claussandcclauss 7bd1e983c3 ruff rules RET for return statements (#15301)
* updating DIRECTORY.md

* ruff rules RET for return statements

---------

Co-authored-by: cclauss <cclauss@users.noreply.github.com>
2026-09-12 21:33:52 +02:00
SYED ANNAS JAWED b7f4f02ee6 fix: use averaged ranks for ties in Spearman, guard n<2 (#14889) 2026-09-10 12:22:25 +02:00
SudoShellzandsudo-ai-git df92771a19 fix(maths): defer Matrix type annotations so import does not NameError (#15265)
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>
2026-09-10 07:42:13 +02:00
Tushar TyagiCopilotpre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
62d049a60f feat: add numerical laplace transform (#14602)
* 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>
2026-09-08 17:54:08 +02:00
iQuantumpre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>Christian Clauss
3374edec1c Add Sieve of Atkin algorithm for efficient prime generation (#12974)
* 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>
2026-09-08 17:51:29 +02:00
debesh00800debeshpre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>Christian Clauss
16e3b40408 Add Brent's Method for root finding (numerical analysis) (#13063)
* 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>
2026-09-08 17:43:43 +02:00
Felipe Fernandes — Systems & AI Engineerandpre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> 657c967afb Add Tonelli-Shanks algorithm for modular square roots (#14995)
* 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>
2026-09-08 15:50:20 +02:00
NostraWhopre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>Christian Clauss
beca49787a Add improved doctrings and doctests for math/perfect_number.py (#12830)
* 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>
2026-09-08 15:28:10 +02:00
Arijit Kumar Daspre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>Christian Clausscclauss
301d111954 Create logarithmic_series.py (#12344)
* 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>
2026-09-08 15:21:36 +02:00
Reekapre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>Christian Clauss
321cff5004 Add doctests for sum_of_arithmetic_series function (#12285)
* 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>
2026-09-08 15:19:42 +02:00
Tejas Varshneypre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>Christian Clausscclauss
de3df05a9c Added Trailing Zero Algo (#12104)
* 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>
2026-09-08 15:16:36 +02:00
Thomas GermerChristian Clausscclausspre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
bfb53368d5 Add cholesky_decomposition.py (#11848)
* Add cholesky_decomposition

* Simplify equations, rename variables

* Enforce symmetry on A

* Fix typo

* Rename variables

* Rename variables

* updating DIRECTORY.md

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: Christian Clauss <cclauss@me.com>
Co-authored-by: cclauss <cclauss@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2026-09-08 15:12:40 +02:00
ARNAV RAJTianyi Zhengpre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>Christian Clauss
21fea6ac72 feat(timing): enhance timing function with adaptive units and run averaging (#11834)
* 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>
2026-09-08 15:12:00 +02:00
FireCoder-Npre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>Christian Clausscclauss
da48fb864c Add files via upload (#11784)
* 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>
2026-09-08 15:08:45 +02:00
Soham Kotharipre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>Christian Clausscclauss
b050e30673 weddle's integration rule (#11773)
* 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>
2026-09-08 15:08:02 +02:00
alex-buchananAlexBpre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>Christian Clausscclauss
d9bb1ab9e3 added convolution (#11202)
* added convolution

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* fixed ruff issues

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* fixing ruff errors

* addressing automated concerns

* addressing automated concerns

* addressing automated concerns

* addressing automated concerns

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* addressing automated concerns

* updating DIRECTORY.md

* Apply suggestion from @cclauss

---------

Co-authored-by: AlexB <acbucha@clemson.edu>
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>
2026-09-08 14:58:45 +02:00
92af64afcd Added function that calculates Pell numbers (#10343)
* 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>
2026-09-08 14:56:56 +02:00
Achal Jainpre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>Christian Clausscclauss
84e7972ee9 Added Derangements Calculator (#9927)
* Added Derangement calculator

* Updated derangement.py

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Updated derangement.py

* updating DIRECTORY.md

* Apply suggestion from @cclauss

---------

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>
2026-09-08 14:54:09 +02:00
liyana nishaat peyyetipre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>Christian Clauss
71bd79a781 maths: add weighted_average function (#14850)
* 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>
2026-09-08 14:41:55 +02:00
Jashwanthallenkiandpre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> bc2f6ebb15 Enhance softmax with numerical stability and axis parameter (#13409)
* 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>
2026-09-08 14:39:16 +02:00
Sanchi AgarwalandChristian Clauss 96c429d257 Fix sumset docstring (#15038)
* Fix sumset docstring

* Add empty set test for sumset

---------

Co-authored-by: Christian Clauss <cclauss@me.com>
2026-09-08 14:33:58 +02:00
Kanika Katareandpre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> 12ad81be42 Fix matrix exponentiation type annotations (#15076)
* 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>
2026-09-06 21:10:37 +02:00
kvadrikChristian Clausspre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
a9ddc6168d Update area.py (#14307)
* 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>
2026-09-06 00:09:04 +02:00
kvadrikChristian Clausspre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
ced4c091df Update volume.py (#14291)
* 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>
7691204a88 Added some Unit Tests to increase test code coverage (#13903)
* 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>
2026-09-05 23:35:55 +02:00
Xin@@Gar dfc6e7789c feat: add Kaprekar's Constant (6174) algorithm to special numbers (#13862) 2026-09-05 23:20:08 +02:00
EraollandEraoll 68e35412e8 maths: add Kaprekar number implementation (#14562)
Co-authored-by: Eraoll <eraoll@r3net.fr>
2026-09-05 23:19:01 +02:00
priya-sundaram-devandpre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> bfa655ecea deps: migrate from httpx to httpx2 (pydantic's maintained fork) (#15192)
* 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>
2026-09-05 09:26:45 +02:00
mankala sharathchandrapre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>Christian Clauss
4e67184aa7 maths/recursive_digit_sum.py (#12141)
* 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>
2026-09-04 23:10:13 +02:00
Satyam Kumarandkumarsatyam9378-art 25a312ded5 Fix docstring copy-paste error in maths/sumset.py (#15052)
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>
2026-08-25 16:09:01 +02:00
pre-commit-ci[bot]cclausspre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>Maxim SmolskiyMaximSmolskiyChristian Clausscopilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
840ca00ad3 [pre-commit.ci] pre-commit autoupdate (#14325)
* [pre-commit.ci] pre-commit autoupdate

updates:
- [github.com/astral-sh/ruff-pre-commit: v0.14.14 → v0.15.4](https://github.com/astral-sh/ruff-pre-commit/compare/v0.14.14...v0.15.4)
- [github.com/tox-dev/pyproject-fmt: v2.12.1 → v2.16.2](https://github.com/tox-dev/pyproject-fmt/compare/v2.12.1...v2.16.2)
- [github.com/abravalheri/validate-pyproject: v0.24.1 → v0.25](https://github.com/abravalheri/validate-pyproject/compare/v0.24.1...v0.25)

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* updating DIRECTORY.md

* Configure mypy to target Python 3.14 and update to v1.20.0

Agent-Logs-Url: https://github.com/TheAlgorithms/Python/sessions/332481be-4c5f-4412-abf8-6ef4a3913828

Co-authored-by: cclauss <3709715+cclauss@users.noreply.github.com>

* [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>
Co-authored-by: MaximSmolskiy <MaximSmolskiy@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: cclauss <3709715+cclauss@users.noreply.github.com>
2026-04-02 02:50:30 +02:00
Tejas RahaneandMaxim Smolskiy 135c748e55 Fix doctests in factorial_recursive function (#13703)
* 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>
2026-03-11 10:56:30 +03:00
Jaime Fernández González af131b7c3f Remove duplicated return statement in area_reg_polygon (#14362) 2026-03-10 08:44:09 +03:00
Shivang Aryapre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>Maxim Smolskiy
1ae906a97b Fix incorrect doctest references in fibonacci functions (#14200)
* 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>
2026-03-09 07:49:15 +03:00
AnushaAnusha-DeviEpre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>Maxim Smolskiy
f5c3e7c808 Replace assert-based validation with explicit errors in modular_division (#14204)
* 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>
2026-03-09 07:37:31 +03:00
Yaadhuupre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>Maxim Smolskiy
84b59c8781 Handle gcd(0, 0) edge case (#14215)
* 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>
2026-03-09 07:08:51 +03:00
umutKaracelebipre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>Maxim Smolskiy
0324e6098d style: add type hints to matrix_exponentiation.py (#14288)
* style: add type hints to matrix_exponentiation.py

* Refactor kth_permutation and fix linter errors

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Delete machine_learning/linear_discriminant_analysis.py

* Revert "Delete machine_learning/linear_discriminant_analysis.py"

This reverts commit de29647311.

* Update linear_discriminant_analysis.py

* Update kth_lexicographic_permutation.py

* Update matrix_exponentiation.py

* Update matrix_exponentiation.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>
2026-03-09 06:18:15 +03:00
Md MahiuddinandMaxim Smolskiy e2a78d4e76 Add test for non-integer input to factorial function (#13024)
* Add test for non-integer input to factorial function

* Update test_factorial.py

---------

Co-authored-by: Maxim Smolskiy <mithridatus@mail.ru>
2025-10-20 03:59:36 +03:00
8edc478a19 Adding missing return type to pi_estimator function (#13427)
- 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>
2025-10-17 03:36:38 +03:00
OmkaarChristian Clausspre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
3cea94179d Fix a few typos (#13346)
* 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>
2025-10-15 19:35:55 +02:00
iddu e731514bd5 Fix typo and function call in maths module (#13515) 2025-10-15 16:03:33 +02:00
Christian Clauss 9372040da9 Test on Python 3.14 (#12710) 2025-10-07 18:23:37 +02:00
Christian Claussandpre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> 63180d7e24 pre-commit autoupdate 2025-09-11 (#12963)
* 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>
2025-09-13 01:56:14 +03:00
Juan DupierrisJuanitoupipoupre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>Maxim Smolskiy
8f1a6b0ca0 Adding the function is_proth_number (#12399)
* 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>
2025-09-08 02:41:07 +03:00
__Adityaandpre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> 4394fd93d3 Weierstrass Method (#12877)
* 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>
2025-08-29 17:33:43 +01:00