Commit Graph
3923 Commits
Author SHA1 Message Date
Christian Clauss a4ca6eedbe Merge branch 'master' into copilot/fix-sphinx-docs 2026-09-13 15:46:47 +02:00
Hardik PawarChristian Clausspre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>Hardvancclauss
8339a95efc Improve comments, add doctests to coloring.py (#11589)
* Improve comments, add doctests to coloring.py

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

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

* Fix ruff errors

* Update backtracking/coloring.py

Co-authored-by: Christian Clauss <cclauss@me.com>

* Update backtracking/coloring.py

Co-authored-by: Christian Clauss <cclauss@me.com>

* Update backtracking/coloring.py

Co-authored-by: Christian Clauss <cclauss@me.com>

* Update backtracking/coloring.py

Co-authored-by: Christian Clauss <cclauss@me.com>

* Update backtracking/coloring.py

Co-authored-by: Christian Clauss <cclauss@me.com>

* Remove type hints for function docstrings

* updating DIRECTORY.md

* updating DIRECTORY.md

* pyproject.toml: tool.rumdl.per-file-ignores."index.md" = ["MD040"]

* Clean up toctree in index.md

Removed unnecessary comment from the toctree directive.

---------

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: Hardvan <Hardvan@users.noreply.github.com>
Co-authored-by: cclauss <cclauss@users.noreply.github.com>
2026-09-13 15:45:56 +02:00
Christian Clauss 9e505219cd Fix comment formatting in index.md 2026-09-13 15:30:31 +02:00
pre-commit-ci[bot] 71684901f2 [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
2026-09-13 13:15:32 +00:00
Christian Clauss b5e490843f tool.rumdl.per-file-ignores."index.md" = ["MD040"] 2026-09-13 15:15:19 +02:00
Copilot 3700761c11 updating DIRECTORY.md 2026-09-13 11:54:13 +00:00
copilot-swe-agent[bot]andcclauss aadfe1a720 fix: render Sphinx toctree on docs homepage
Co-authored-by: cclauss <3709715+cclauss@users.noreply.github.com>
2026-09-13 11:53:51 +00:00
copilot-swe-agent[bot] e0349cbfa5 Initial plan 2026-09-13 11:51:29 +00:00
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
tomatotomataandChristian Clauss d86f4fe5d9 fix: reject non-integer bucket counts (#14991)
* fix: reject non-integer bucket counts

Signed-off-by: ahmadalguydi <ahmadalgaidy@hotmail.com>

* Update bucket_sort.py

---------

Signed-off-by: ahmadalguydi <ahmadalgaidy@hotmail.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
2026-09-13 13:31:09 +02:00
shreya-learn-exploresShreyapre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>Christian Clauss
3cbb2b9afc Improve insertion_sort docstring with complexity analysis (#14875)
* Improve insertion_sort docstring with complexity analysis

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

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

* Fix doctest formatting

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

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

* Apply suggestion from @cclauss

---------

Co-authored-by: Shreya <youremail@example.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-13 13:24:40 +02:00
Kanika Katareandpre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> 76895aafb7 Fix kahns algo sparse vertex performance (#15072)
* fix: sub-interval midpoint formula in ternary search

* fix(graphs): use deque and dict for kahns algorithm sparse vertices

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

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

* perf(graphs): benchmark kahns queue performance

* perf(graphs): benchmark topological_sort queue performance

* style(graphs): fix line length in kahns algorithm benchmark

* refactor(graphs): remove benchmark baseline and microbenchmark from kahns_algorithm_topo

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2026-09-13 13:07:26 +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
Dharshini_RSChristian Clausspre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
aa38af81c9 fix:bucket count type (#15063)
* fix:bucket count type

* fixed TypeError

* Refine docstring and adjust return statement

Updated docstring for partition_liked_list method to clarify behavior. Changed return statement from None to None for consistency.

* Add script to map open PRs to modified files

This script lists all open pull requests in the current directory's git repository and maps each file touched by any open PR to its corresponding PR numbers. It outputs the results in GitHub-flavored Markdown format.

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

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

* Add noqa comments for subprocess calls

Add noqa comments to suppress specific linting warnings.

---------

Co-authored-by: Christian Clauss <cclauss@me.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2026-09-13 09:25:21 +02:00
Aditya BalotraandChristian Clauss 7b5e704d9f Gauss-Jordan Elimination (#12876)
* This commit adds a function that performs Gauss–Jordan elimination
to solve a system of linear equations represented by Ax = b.

The function reduces the coefficient matrix A to its reduced row echelon
form (RREF) and transforms the RHS vector b accordingly. It includes:

- Input validation for dimension compatibility
- Full support for floating-point matrices
- Doctests demonstrating example use cases and expected output

* add URL

* Add reference link for Gaussian elimination

Added a reference link to the Gaussian elimination Wikipedia page.

* Update gauss_jordan.py

---------

Co-authored-by: Christian Clauss <cclauss@me.com>
2026-09-13 08:53:12 +02:00
余枫anddeerred643-star ab3783114e Add clear least significant set bit operation (#15305)
Co-authored-by: deerred643-star <deerred643-star@users.noreply.github.com>
2026-09-13 08:34:05 +02:00
Inesh Agarwalpre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>Christian Clausscclauss
bde91502db Add XOR Linked List implementation with doctests (#13699)
* Add XOR Linked List implementation with doctests

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

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

* Add XOR Linked List implementation with doctests

* Add XOR Linked List implementation with doctests

* Add XOR Linked List implementation with doctests

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

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

* updating DIRECTORY.md

* Refine docstring and variable comment in XOR linked list

Updated docstring for clarity and corrected 'ids' to 'IDs'.

* Refactor Node class to use dataclass

Refactor Node class to use dataclass for cleaner syntax.

* [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>
Co-authored-by: cclauss <cclauss@users.noreply.github.com>
2026-09-13 08:27:13 +02:00
Martin Oywa 0051e4eae2 Add partition_list in linked_list (#13325) 2026-09-13 08:12:23 +02:00
Martin Oywa b59e85983f Add find kth_element_from_end in linked_lists (#13322)
* Add find kth_element_from_end in linked-lists

* Update kth_element_from_end docstring

* Update kth_element_from_end k to position
2026-09-13 08:10:38 +02:00
fze 1429eec098 Add move-to-front transform (#14743) 2026-09-13 08:05:01 +02:00
cian-psandChristian Clauss cc142b1ef5 Implemention of an algorithm for image style reconstruction (#14233)
* Add gramian algorithm

* Update docstring with additional references

Added references to Gram matrices and neural style transfer in the docstring.

---------

Co-authored-by: Christian Clauss <cclauss@me.com>
2026-09-13 08:02:08 +02:00
c9a815a41f Triangle Centers (#11201)
* Addition to the Geometry Folder with Triangle that calculates the different triangle centers

* Addition to the Geometry Folder with Triangle that calculates the different triangle centers

* Original triangle center w/fixes for automated testing

* triangles, added more fixes for automated testing

* trying to rename triangle.py

* Fixed a documentation error

* Removed a space I suspect is preventing the automated code reviewer from completing

* Fixed a documentation error

* updating DIRECTORY.md

* Apply suggestion from @cclauss

---------

Co-authored-by: AlexB <acbucha@clemson.edu>
Co-authored-by: Christian Clauss <cclauss@me.com>
Co-authored-by: cclauss <cclauss@users.noreply.github.com>
2026-09-13 08:00:52 +02:00
Adhithya Laxman d7c0a1fe7d Add Adagrad optimizer implementation (#13681)
- Implements Adagrad (Adaptive Gradient) using pure NumPy
- Adapts learning rate individually for each parameter
- Includes comprehensive docstrings and type hints
- Adds doctests for validation
- Provides usage example demonstrating convergence
- Follows PEP8 coding standards
- Part of issue #13662
2026-09-13 07:07:51 +02:00
Jubayer Ahmed Sojib 9c8a3c6ca6 Add Hopcroft-Karp algorithm for maximum bipartite matching (#15293)
* Add Hopcroft-Karp algorithm for maximum bipartite matching

* refactor(graphs): address Copilot and keeper reviews with private sentinel, iterative DFS, and tests
2026-09-13 07:05:28 +02:00
Aranya DuttaChristian Clausspre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
febcf134ee Add dynamic programming solution for Egg Dropping Problem (#12066)
* Add dynamic programming solution for Egg Dropping Problem

* Revert changes to .pre-commit-config.yaml

Co-authored-by: Christian Clauss <cclauss@me.com>

* [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: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2026-09-13 06:55:45 +02:00
JAI VIGNESH JandChristian Clauss 2c88e22de7 Fix doctest q fourier transform.py #9943 (#10624)
* Fixed failed examples

* Added testmod function

* Revert pre-commit changes

Co-authored-by: Christian Clauss <cclauss@me.com>

* Add print statements for quantum Fourier transform output

Added print statements to display the total count for the quantum Fourier transform state when the module is run directly.

---------

Co-authored-by: Christian Clauss <cclauss@me.com>
2026-09-13 06:34:30 +02:00
Varshini Shreepre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>Christian Clausscclauss
14c971ffe6 New (#12295)
* Fixed

* Added TSP

* Fixes 12192

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

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

* updating DIRECTORY.md

* Rename travelling_salesman_problem.py to graphs/travelling_salesman_problem.py

* updating DIRECTORY.md

* Fix typo in TSP validation comments

* Fix expected output for TSP function test case

Updated expected output for travelling_salesman_brute_force function.

* Fix error messages in TSP validation functions

* Modify doctest to ignore exception details

Updated doctest to ignore exception details for invalid graph input.

* Fix doctest formatting for validate_graph function

Updated doctest format for invalid graph validation.

* Update doctests in validate_graph function

---------

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-13 01:12:34 +02:00
priya-sundaram-dev 945b5ab9ee data_structures: add return type annotations (ANN201) (#15306)
Annotate the unambiguous, primitive/container-returning public methods
flagged by ruff ANN201 across data_structures/ (int/bool/float/list/dict
and one fluent self-return). Reduces ANN201 in this directory from 58 to 36.

Element-typed and sentinel-union returns (e.g. node .data getters,
dict|False in the Sudoku solver) are intentionally left for follow-up,
since they warrant generics/TypeVar or a type checker rather than a guess.

Refs #15296
2026-09-13 00:10:48 +02:00
Ahmad ObeidChristian Clausspre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
f0391e0586 improve computer-vision-readme (#14143)
* improve computer-vision-readme

* Clean up blank lines in README.md

Removed unnecessary blank lines in the README.

* [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: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2026-09-12 23:35:20 +02:00
Mahima Agarwal 585392e0a9 Add computer_vision\otsu_threshold.py (#11429) 2026-09-12 23:30:45 +02:00
ParikshitGupta2605andChristian Clauss 242bd232a9 Fix cnn prediction (#14904)
* Fix CNN prediction threshold for binary classification

* Use ternary operator for binary prediction

---------

Co-authored-by: Christian Clauss <cclauss@me.com>
2026-09-12 23:27:26 +02:00
Jubayer Ahmed Sojib 2f4a9fe998 feat(dynamic_programming): add Needleman-Wunsch global sequence alignment algorithm (#15294) 2026-09-12 22:53:24 +02:00
dwaddle 4c8f5dcf65 docs: add docstrings and doctests to simple_substitution_cipher (#15108) 2026-09-12 22:48:07 +02:00
余枫andChristian Clauss 4dcd68eedd sorts: make exchange_sort generic for comparable items (#15304)
* sorts: make exchange_sort generic for comparable items

* Ints and floats are comparable

---------

Co-authored-by: Christian Clauss <cclauss@me.com>
2026-09-12 22:34:45 +02:00
Christian Clauss 02716a9101 ruff rule ANN201 missing-return-type-undocumented-public-function (#15296) 2026-09-12 21:57:24 +02:00
Milad Khoshdel d0370dba57 fix(strings): avoid counting false matches in z-function search (#15302) 2026-09-12 21:52:41 +02:00
github-actions[bot]andcclauss db01fc3f26 chore: refresh Hacktoberfest 2026 prep tracker (#15295)
Co-authored-by: cclauss <cclauss@users.noreply.github.com>
2026-09-12 21:51:40 +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
Christian Clauss a11c636a0e Ruff rules ANN for type annotations (#15297) 2026-09-12 21:16:57 +02:00
priya-sundaram-devandChristian Clauss 341e1da95b sorts: add cross-algorithm benchmark (sorts/benchmark_sorts.py) (#15284)
* sorts: add benchmark_sorts.py comparing algorithms on shared datasets

* Enhance type safety and clarity in benchmark_sorts.py

Updated the benchmark_sorts.py script to improve type safety and added a Comparable protocol for generic sorting. Adjusted comments for clarity and fixed minor formatting issues.

---------

Co-authored-by: Christian Clauss <cclauss@me.com>
2026-09-12 18:51:52 +02:00
Ashwin R dbf22d3c48 sorts: make heap sort support comparable items (#15291)
* sorts: make heap sort support comparable items

* style: remove unnecessary blank lines from heap sort
2026-09-12 13:02:21 +02:00
priya-sundaram-dev 611418cfb2 machine_learning: add numeric doctests to gradient_descent (#15286) 2026-09-12 11:18:13 +02:00
Vibhor GautamandChristian Clauss 12d064871b fix: use geodetic latitudes in haversine distance formula (#14351)
* fix: use geodetic latitudes in haversine distance formula

The implementation was incorrectly using reduced latitudes (via a
flattening factor from WGS84 ellipsoid constants) instead of raw
geodetic latitudes. Reduced latitudes are appropriate for ellipsoidal
models like Lambert's formula, but the Haversine formula operates on
a sphere and should use geodetic latitudes directly.

Changes:
- Use radians(lat) directly instead of computing reduced latitudes
  with atan((1 - flattening) * tan(radians(lat)))
- Replace equatorial radius (6378137m) with mean Earth radius
  (6371000m) for better spherical approximation
- Remove unused WGS84 ellipsoid constants (AXIS_A, AXIS_B)
- Remove unused imports (atan, tan)
- Add edge case and cross-continental doctests

Fixes #11308

* fix: update Lambert's to use corrected haversine radius for central angle

Lambert's ellipsoidal distance computes the central angle sigma by
dividing the haversine distance by a radius. Previously both functions
used the same equatorial radius (6378137m), so the values cancelled
out. After correcting haversine to use the mean Earth radius (6371000m),
Lambert's must divide by the same radius to recover the correct angle.

Also update the expected doctest values to match the corrected
haversine output.

Fixes #11308

* Fix typos

Updated the docstring for the haversine_distance function to improve clarity and fix minor grammatical issues.

* Fix typos in docstring and variable names

* Clarify note on using haversine_distance.py

Updated the note to clarify the use of haversine_distance.py.

---------

Co-authored-by: Christian Clauss <cclauss@me.com>
2026-09-12 10:11:49 +02:00
Orji PatriciaandChristian Clauss d502013438 sorts: make comb_sort generic for comparable items (#15288)
* sorts: make comb sort generic for comparable items

* tests: cover comb sort incomparable inputs

* Update sorts/comb_sort.py

* Apply suggestion from @cclauss

* Apply suggestion from @cclauss

---------

Co-authored-by: Christian Clauss <cclauss@me.com>
2026-09-12 07:53:55 +02:00
priya-sundaram-dev 3e34e8ef75 machine_learning: pin numeric output of k_means_clust with doctests (#15285) 2026-09-12 02:12:26 +02:00
0fe748a33e Add docstring to build_tree() (#15091)
Co-authored-by: Jarvis Jeason Jacob <jarvis@Jarviss-MacBook-Pro.local>
Co-authored-by: Christian Clauss <cclauss@me.com>
2026-09-12 01:53:33 +02:00
e548737115 Implement K-Medoids Clustering Algorithm #13488 (#13510)
* Added k_medoids algorithm

* updating DIRECTORY.md

---------

Co-authored-by: Christian Clauss <cclauss@me.com>
Co-authored-by: cclauss <cclauss@users.noreply.github.com>
2026-09-12 01:38:47 +02:00