* Add digital root algorithm
* refactor: use descriptive parameter name `number` instead of `n` (algorithms-keeper)
Also see: project_euler/problem_092/sol1.py
* 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>
* 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>
* 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.
* 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>
* 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>
* 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>
* 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>
* 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>
- 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
* Add Hopcroft-Karp algorithm for maximum bipartite matching
* refactor(graphs): address Copilot and keeper reviews with private sentinel, iterative DFS, and tests
* 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>
* 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>
* 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>
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
* 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>
* Fix CNN prediction threshold for binary classification
* Use ternary operator for binary prediction
---------
Co-authored-by: Christian Clauss <cclauss@me.com>
* 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>
* 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>