* fix: raise ValueError in encode() for non-lowercase input
encode() previously accepted uppercase letters, digits, and other
non-lowercase characters silently, producing incorrect/out-of-range
values (e.g. negative numbers for uppercase letters) instead of
failing. Add input validation using str.islower() and str.isalpha()
to raise a ValueError when the input isn't purely lowercase a-z.
Added a doctest covering the new error case.
* resolved doctest
* Fix Ruff 0.16 lint failures
* Enhance encode function error handling examples
Update error handling in encode function to include examples for mixed case and invalid characters.
* Fix indentation in test_cancer_data function
* [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 invalid Python 2 syntax in except clause
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Update ruff-pre-commit version to v0.16.1
* Fix indentation in test_cancer_data 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>
* docs: expand bubble sort docstrings with algorithm explanation
Add a concise description of how bubble sort works (repeated
adjacent comparisons/swaps until a pass makes no swaps) and note
time/space complexity for both the iterative and recursive
implementations. No behavior changes; all existing doctests pass.
* Fix Ruff 0.16 lint failures
* S310
---------
Co-authored-by: Christian Clauss <cclauss@me.com>
* Fix typos in Johnson's algorithm (nd -> and) to pass codespell
* Rename type aliases and h parameter to follow snake_case and descriptive naming
* Potential fix for pull request finding
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
---------
Co-authored-by: John Law <johnlaw.po@gmail.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
* Add type hints to tim_sort.py, relates to #14457
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Fix ruff PYI041 error: use float instead of int | float
* Fix mypy error: support str and tuple inputs as defined in doctests
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Fix ruff E501: wrap binary_search parameters to respect 88 char limit
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Refactor generics to use Python 3.12 type parameter syntax (PEP 695)
* Use Any from typing to resolve mypy list unpacking bugs
* [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: John Law <johnlaw.po@gmail.com>
* Add latitude and longitude validation with doctests
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Update lamberts_ellipsoidal_distance.py
---------
Co-authored-by: Pamela Cano <pamelacano@MacBook-Pro-de-Pamela.local>
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 some doctests to algos in backtracking
* [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>
* 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>
Fixed bug in bubble_sort_recursive docstring where the doctest was calling bubble_sort_iterative([]) instead of bubble_sort_recursive([]). This was a copy-paste error that would cause the doctest to pass even if bubble_sort_recursive had issues with empty lists.
Change:
- Line 71: Changed '>>> bubble_sort_iterative([])' to '>>> bubble_sort_recursive([])'
This ensures the doctest properly validates the recursive implementation.
Co-authored-by: Maxim Smolskiy <mithridatus@mail.ru>
* Fix return type description in bubble_sort.py
Better (clearer, standard phrasing):
:return: the same collection ordered in ascending order
* Update bubble_sort.py
---------
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
* Update kth_lexicographic_permutation.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>
* 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>
* docs: refine docstring and simplify reverse_letters implementation
Updated the docstring for clarity and improved the logic for reversing words.
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Update reverse_letters.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>
* 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 type hints and improve code quality for generate_parentheses_iterative
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Fix line length issue
* Update generate_parentheses_iterative.py
* Update generate_parentheses_iterative.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>
* feat: add Graham Scan convex hull algorithm
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* fix: address pre-commit issues
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* chore: Algorithm-Keeper's comments addressed
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: John Law <johnlaw.po@gmail.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
* Add Jarvis March (Gift Wrapping) convex hull algorithm
* Use descriptive parameter names per algorithms-keeper review
* Update jarvis_march.py
* Update jarvis_march.py
* fix: add pytest marker
* Update jarvis_march.py
* feat: removed doctests and created a separate test file for CI to pass
* Update jarvis_march_unit.py
* Update jarvis_march.py
* Update jarvis_march_unit.py
* feat: added test folder with tests to pass CI checks
* fix: duplicate points handled
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* fix: fixed ruff errors
* [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>
* feat: add sliding window maximum using monotonic deque
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* feat: add sliding window maximum using monotonic deque
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>