Commit Graph

3583 Commits

Author SHA1 Message Date
Ronald Ngounou
b0920454cc Add unit tests to binary_tree_path_sum.py (#11833)
* test: Add unit tests

* test: Add successful tests in binaree_tree_path_sum

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

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

* Update binary_tree_path_sum.py

* Update binary_tree_path_sum.py

* Update binary_tree_path_sum.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>
2025-08-30 11:49:44 +03:00
Abhijit Kumar Singh
1e0d3173fa Specify space complexity for merge sort (#11749)
* Added space complexity

Space complexity of merge sort is a key factor, when compared to quick sort

* Update merge_sort.py

---------

Co-authored-by: Maxim Smolskiy <mithridatus@mail.ru>
2025-08-30 03:37:13 +03:00
Sohail khan
c5de3954cc Add new test for bucket sort algorithm in sorts/bucket_sort.py (#11605)
* Add new test for bucket sort algorithm in sorts/bucket_sort.py

* Update fractional_knapsack.py

* Update matrix_class.py

* Update bucket_sort.py

* Update bucket_sort.py

---------

Co-authored-by: Maxim Smolskiy <mithridatus@mail.ru>
2025-08-30 03:28:38 +03:00
Venkata Ramana Menda
488f143b8c Performance: 25% faster Project Euler 73 #10503 (#11553)
* Seperate slow_solution and solution

* Add performance benchmark

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

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

* Fix issues

* Update sol1.py

* Update sol1.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>
2025-08-30 03:16:21 +03:00
Aasheesh
5c50572476 Fixing stock_span_problem.py (#10540)
* Adding doctests in simpson_rule.py

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

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

* Update stock_span_problem.py

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

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

* Update subset_generation.py

* Update subset_generation.py

* Update data_structures/stacks/stock_span_problem.py

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

* Update stock_span_problem.py

* Update data_structures/stacks/stock_span_problem.py

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

* Update stock_span_problem.py

* Update stock_span_problem.py

* updating DIRECTORY.md

* Update stock_span_problem.py

* Update stock_span_problem.py

* Update stock_span_problem.py

* Update stock_span_problem.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>
Co-authored-by: Maxim Smolskiy <mithridatus@mail.ru>
Co-authored-by: MaximSmolskiy <MaximSmolskiy@users.noreply.github.com>
2025-08-30 02:17:31 +03:00
__Aditya
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
Praful Katare
54aa73fdf0 Fixes bugs in graphs/dijkstra_algorithm.py (#10092)
* Fixes bug in PriorityQueue Algorithm; Fixes syntax in code for array.

* Update dijkstra_algorithm.py

* Update dijkstra_algorithm.py

* Update dijkstra_algorithm.py

* Update dijkstra_algorithm.py

---------

Co-authored-by: Maxim Smolskiy <mithridatus@mail.ru>
2025-08-28 01:45:05 +03:00
Prathamesh Gadekar
84f101ca6e Add/generate parentheses iterative approach (#10024)
* Generate parantheses iterative

* Generate parantheses iterative

* Generating parantheses code using iterative approach

* Update generate_parentheses_iterative.py

* updating DIRECTORY.md

* Update generate_parentheses_iterative.py

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

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

* Update generate_parentheses_iterative.py

* Update generate_parentheses_iterative.py

* Update generate_parentheses_iterative.py

---------

Co-authored-by: nightmare10123 <pgadekar10123@gmail.com>
Co-authored-by: Maxim Smolskiy <mithridatus@mail.ru>
Co-authored-by: MaximSmolskiy <MaximSmolskiy@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2025-08-28 01:22:12 +03:00
architmaheshwari99
e6b5d26d5c Combination sum fix and test cases (#10193)
* fixed_incorrect_test_combination_sum

* reverting fn arg

* ruff

* Update combination_sum.py

* Update combination_sum.py

---------

Co-authored-by: Maxim Smolskiy <mithridatus@mail.ru>
2025-08-28 00:07:46 +03:00
Mary-0165
0c39e43af7 Algorithm to find unique prime factors (#9935)
* algorithm to find unique prime factors

* Update prime_factors.py

* Update prime_factors.py

* Update prime_factors.py

---------

Co-authored-by: Maxim Smolskiy <mithridatus@mail.ru>
2025-08-27 23:55:27 +03:00
Shreyash Kashyap
2fa65c7d92 Improve blockchain/README.md (#9630)
* Update README.md

* Update blockchain/README.md

Co-authored-by: Tianyi Zheng <tianyizheng02@gmail.com>

* Update blockchain/README.md

Co-authored-by: Tianyi Zheng <tianyizheng02@gmail.com>

* Update blockchain/README.md

Co-authored-by: Tianyi Zheng <tianyizheng02@gmail.com>

* Update blockchain/README.md

Co-authored-by: Tianyi Zheng <tianyizheng02@gmail.com>

* Update blockchain/README.md

Co-authored-by: Tianyi Zheng <tianyizheng02@gmail.com>

* Update blockchain/README.md

Co-authored-by: Tianyi Zheng <tianyizheng02@gmail.com>

* Update README.md

---------

Co-authored-by: Maxim Smolskiy <mithridatus@mail.ru>
Co-authored-by: Tianyi Zheng <tianyizheng02@gmail.com>
2025-08-27 23:41:04 +03:00
Om Ashishkumar Soni
b486ac60e6 added coordinate_compression (#9317)
* added coordinate_compression algorithm

* added coordinate_compression & doctest

* adding return type hints and utilized enumerate

* adding exmaple usage in main function

* added type hints, for list and dict

* updating DIRECTORY.md

* Update other/coordinate_compression.py

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

* Update other/coordinate_compression.py

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

* Update other/coordinate_compression.py

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

* Update other/coordinate_compression.py

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

* Update other/coordinate_compression.py

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

* Update other/coordinate_compression.py

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

* Update other/coordinate_compression.py

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

* Update other/coordinate_compression.py

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

* Update coordinate_compression.py

* Create coordinate_compression.py

* updating DIRECTORY.md

* Delete other/coordinate_compression.py

* updating DIRECTORY.md

* Update coordinate_compression.py

* Update coordinate_compression.py

* Update coordinate_compression.py

* Update coordinate_compression.py

* Update coordinate_compression.py

* Update coordinate_compression.py

* Update coordinate_compression.py

* Update coordinate_compression.py

* Update coordinate_compression.py

---------

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: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2025-08-27 22:02:14 +03:00
Wei Jiang
4961b3aa89 Enhancement of the knapsack algorithm with memorization and generalisation (#9295)
* enhance knapsack problem

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

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

* wei/refactor code

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

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

* Update test_knapsack.py

* Update knapsack.py

* Update test_knapsack.py

* Update knapsack.py

* Update knapsack.py

* Update knapsack.py

* Update knapsack.py

* Update knapsack.py

* Update test_knapsack.py

---------

Co-authored-by: weijiang <weijiang@weijiangs-MacBook-Pro.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>
2025-08-27 01:10:22 +03:00
Sharan Sukesh
44cf167175 Create cyclic_sort.py (#9256)
* Create cyclic_sort.py

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

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

* Update cyclic_sort.py

* updating DIRECTORY.md

* Update cyclic_sort.py

* Update cyclic_sort.py

* Update cyclic_sort.py

* Update cyclic_sort.py

* Update cyclic_sort.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>
Co-authored-by: MaximSmolskiy <MaximSmolskiy@users.noreply.github.com>
2025-08-26 21:42:14 +03:00
Mindaugas
55db5a1b8d Add new solution for the euler project problem 9 (#12771)
* Add new solution for the euler project problem 9 - precompute the squares.

* Update sol4.py

* updating DIRECTORY.md

* Update sol4.py

* Update sol4.py

* Update sol4.py

---------

Co-authored-by: Maxim Smolskiy <mithridatus@mail.ru>
Co-authored-by: MaximSmolskiy <MaximSmolskiy@users.noreply.github.com>
2025-08-26 21:17:18 +03:00
pre-commit-ci[bot]
dc1b2003b4 [pre-commit.ci] pre-commit autoupdate (#12930)
* [pre-commit.ci] pre-commit autoupdate

updates:
- [github.com/astral-sh/ruff-pre-commit: v0.12.9 → v0.12.10](https://github.com/astral-sh/ruff-pre-commit/compare/v0.12.9...v0.12.10)
- [github.com/pre-commit/mirrors-mypy: v1.15.0 → v1.17.1](https://github.com/pre-commit/mirrors-mypy/compare/v1.15.0...v1.17.1)

* Update word_break.py

* Update word_break.py

* Update word_break.py

* Update word_break.py

* Update word_break.py

* Update covid_stats_via_xpath.py

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

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

* Update pyproject.toml

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

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

* Update pyproject.toml

* Update pyproject.toml

* Update covid_stats_via_xpath.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: Maxim Smolskiy <mithridatus@mail.ru>
2025-08-26 15:32:39 +03:00
alejandroaldas
8c1c6c1763 Codex/find and fix a bug (#12782)
* Fix enumeration order in FFT string representation

* updating DIRECTORY.md

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

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

* Update radix2_fft.py

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

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

---------

Co-authored-by: alejandroaldas <alejandroaldas@users.noreply.github.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>
2025-08-25 01:16:05 +03:00
John Liu
b0be304433 Use deque as queue in breadth_first_search_shortest_path_2.py (#12861)
* Fixes #12857 Use collections.deque as queue in graphs BFS shortest path 2

* Use collections.deque as queue in the correct syntax: queue = deque([start])

* Fix CI error due to HTTP 404 on https://finance.yahoo.com/quote/GOOG/\?p\=GOOG

* Undo change in workflows/build.yml as it's fixed in PR 12864

---------

Co-authored-by: Maxim Smolskiy <mithridatus@mail.ru>
2025-08-25 00:59:44 +03:00
S. M. Mohiuddin Khan Shiam
561cc383ec Fix RuntimeError in bipartite-check DFS/BFS and clean up doctests (#12814)
* Fix `RuntimeError` in bipartite-check DFS/BFS and clean up doctests

* Iteration over `graph` mutated by `defaultdict` neighbours caused
  `RuntimeError: dictionary changed size during iteration`.
  – Iterate over `list(graph)` in both DFS and BFS helpers.
* Corrected `if __name__ == "__main__":` typo.
* Updated two doctests that now succeed after the fix.

All doctests now pass (`30/30`), eliminating a critical runtime failure and improving reliability of the graph algorithms.

Co-Authored-By: S. M. Mohiuddin Khan Shiam <147746955+mohiuddin-khan-shiam@users.noreply.github.com>

* Update check_bipatrite.py

* Update check_bipatrite.py

* Update check_bipatrite.py

* Update check_bipatrite.py

* Update check_bipatrite.py

* Update check_bipatrite.py

* Update check_bipatrite.py

* Update check_bipatrite.py

* Update check_bipatrite.py

---------

Co-authored-by: Odio Marcelino <odiomarcelino@gmail.com>
Co-authored-by: Maxim Smolskiy <mithridatus@mail.ru>
2025-08-25 00:47:46 +03:00
Mindaugas
d927d67c4a Update Linked List from sequence script to use doctests (#12766)
* Update comments for linked list script.

* Add doctests for the linked list script.

* Update from_sequence.py

---------

Co-authored-by: Maxim Smolskiy <mithridatus@mail.ru>
2025-08-24 17:48:59 +03:00
Sowndappan S
37b34c2bac perf(strings): optimize anagram signature using frequency counts (#12927)
* fix(strings): use frequency-based signature for anagrams

Replaced the sorting-based signature implementation with a frequency-based
approach using `collections.Counter`. This ensures that the signature
represents both characters and their counts, preventing collisions and
better grouping of true anagrams.

Examples:
- "test" → "e1s1t2"
- "finaltest" → "a1e1f1i1l1n1s1t2"
- "this is a test" → " 3a1e1h1i2s3t3"

Also updated the anagram lookup to use the new frequency-based signatures, making results more accurate and avoiding false positives.

* Refactor anagram function return type to list[str]

* Update anagrams.py

* Update anagrams.py

* Update anagrams.py

* Update anagrams.py

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

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

---------

Co-authored-by: Maxim Smolskiy <mithridatus@mail.ru>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2025-08-24 15:33:18 +03:00
Ahmad Alharbi
d16cac6e4f feat: Add recursive implication function for lists (#12855)
* feat: Add recursive implication function for lists

* Update imply_gate.py

* Update imply_gate.py

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

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

---------

Co-authored-by: Maxim Smolskiy <mithridatus@mail.ru>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2025-08-24 15:08:52 +03:00
conti
060fd8ee2c Fix reverse_bits.py: correct 32-bit reversal and improve docstrings (#12924)
* Fix reverse_bits.py (#12868)

* Update reverse_bits.py

* Update reverse_bits.py

* Update reverse_bits.py

* Update reverse_bits.py

* Update reverse_bits.py

---------

Co-authored-by: Maxim Smolskiy <mithridatus@mail.ru>
2025-08-24 14:49:43 +03:00
Diya
9ddb0272bf Adding doctest for md_prefix function in build_directory_md.py (#12874)
* Adding doctests for md_prefix function in build_directory_md.py

* Update build_directory_md.py

* Update build_directory_md.py

* Update build_directory_md.py

---------

Co-authored-by: Maxim Smolskiy <mithridatus@mail.ru>
2025-08-24 14:22:00 +03:00
Chandra Sekhar Pola
c2b90034a0 Fix code style in README.md (#12843)
* Fix #12840 code style

* Update README.md

---------

Co-authored-by: Maxim Smolskiy <mithridatus@mail.ru>
2025-08-24 14:01:21 +03:00
Milad Khoshdel
a8c5616857 Simplify Capitalize Function (#12879)
* Simplify the capitalize function using ASCII arithmetic to make the algorithm five times faster.

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

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

* Update capitalize.py

* Update capitalize.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>
2025-08-24 13:07:39 +03:00
dependabot[bot]
e224532107 Bump actions/upload-pages-artifact from 3 to 4 (#12922)
Bumps [actions/upload-pages-artifact](https://github.com/actions/upload-pages-artifact) from 3 to 4.
- [Release notes](https://github.com/actions/upload-pages-artifact/releases)
- [Commits](https://github.com/actions/upload-pages-artifact/compare/v3...v4)

---
updated-dependencies:
- dependency-name: actions/upload-pages-artifact
  dependency-version: '4'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-08-23 05:48:47 +02:00
pre-commit-ci[bot]
beb3cfdf28 [pre-commit.ci] pre-commit autoupdate (#12900)
* [pre-commit.ci] pre-commit autoupdate

updates:
- [github.com/astral-sh/ruff-pre-commit: v0.12.8 → v0.12.9](https://github.com/astral-sh/ruff-pre-commit/compare/v0.12.8...v0.12.9)
- [github.com/pre-commit/mirrors-mypy: v1.15.0 → v1.17.1](https://github.com/pre-commit/mirrors-mypy/compare/v1.15.0...v1.17.1)

* 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>
2025-08-19 14:28:03 +02:00
dependabot[bot]
f662b63d1a Bump actions/checkout from 4 to 5 (#12891)
Bumps [actions/checkout](https://github.com/actions/checkout) from 4 to 5.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v4...v5)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-version: '5'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-08-12 09:30:10 +02:00
pre-commit-ci[bot]
d05f5d22d9 [pre-commit.ci] pre-commit autoupdate (#12880)
* [pre-commit.ci] pre-commit autoupdate

updates:
- [github.com/pre-commit/pre-commit-hooks: v5.0.0 → v6.0.0](https://github.com/pre-commit/pre-commit-hooks/compare/v5.0.0...v6.0.0)
- [github.com/astral-sh/ruff-pre-commit: v0.12.5 → v0.12.8](https://github.com/astral-sh/ruff-pre-commit/compare/v0.12.5...v0.12.8)
- [github.com/pre-commit/mirrors-mypy: v1.15.0 → v1.17.1](https://github.com/pre-commit/mirrors-mypy/compare/v1.15.0...v1.17.1)

* 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>
2025-08-11 21:03:20 +02:00
pre-commit-ci[bot]
7a0fee401d [pre-commit.ci] pre-commit autoupdate (#12864)
* [pre-commit.ci] pre-commit autoupdate

updates:
- [github.com/astral-sh/ruff-pre-commit: v0.12.4 → v0.12.5](https://github.com/astral-sh/ruff-pre-commit/compare/v0.12.4...v0.12.5)
- [github.com/pre-commit/mirrors-mypy: v1.15.0 → v1.17.0](https://github.com/pre-commit/mirrors-mypy/compare/v1.15.0...v1.17.0)

* Apply suggestion from @cclauss

* --ignore=web_programming/current_stock_price.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>
2025-07-29 17:27:27 -04:00
pre-commit-ci[bot]
6e1a104877 [pre-commit.ci] pre-commit autoupdate (#12846)
* [pre-commit.ci] pre-commit autoupdate

updates:
- [github.com/astral-sh/ruff-pre-commit: v0.12.3 → v0.12.4](https://github.com/astral-sh/ruff-pre-commit/compare/v0.12.3...v0.12.4)
- [github.com/pre-commit/mirrors-mypy: v1.15.0 → v1.17.0](https://github.com/pre-commit/mirrors-mypy/compare/v1.15.0...v1.17.0)

* 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>
2025-07-21 15:29:24 -04:00
pre-commit-ci[bot]
d1a9486f09 [pre-commit.ci] pre-commit autoupdate (#12781)
* [pre-commit.ci] pre-commit autoupdate

updates:
- [github.com/astral-sh/ruff-pre-commit: v0.11.11 → v0.12.2](https://github.com/astral-sh/ruff-pre-commit/compare/v0.11.11...v0.12.2)
- [github.com/pre-commit/mirrors-mypy: v1.15.0 → v1.16.1](https://github.com/pre-commit/mirrors-mypy/compare/v1.15.0...v1.16.1)

* Update .pre-commit-config.yaml

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
2025-07-11 23:06:49 +02:00
Asim Hanif
5a4a6a5497 Update .pre-commit-config.yaml to reflect current linting and formatt… (#12841)
* Update .pre-commit-config.yaml to reflect current linting and formatting setup

- Replaced outdated references to `black` with the actual tools used in the repo: `ruff` and `ruff-format`.
- Ensured all configured hooks are up to date and relevant to Python development.
- This aligns the linting and formatting setup with the project's actual pre-commit pipeline.
- Improves consistency for contributors by preventing confusion between formatting tools.

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

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

* We use httpx, not requests

* response = httpx.get(request_url, timeout=10).raise_for_status()

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
2025-07-11 22:25:53 +02:00
Bertrand Awenze
ed7c9b51f9 Fix devcontainer build failure (#12837)
* add post-installation script

* set zsh as default terminal and make post-install execution on postcreate

* rename file

* rename script

* Create devcontainers_ci.yml

* Update devcontainer.json

* Update devcontainers_ci.yml

Never push image built here. It's for build testing purpose only.

* postCreateCommand update to reflect that the shell script has been renamed.

* update devcontainer readme file

* trigger workflow only on devcontainer/** changes

* prettier refactor
2025-07-09 14:25:18 +02:00
Christian Clauss
5c05335b27 hill_cipher.py: Use int() to gracefully deal with float input (#12833)
* https://github.com/TheAlgorithms/Python/pull/12821#discussion_r2186998710
2025-07-07 13:58:59 +05:30
Christian Clauss
cd3c3c3130 Various ruff fixes (#12821) 2025-07-06 01:35:29 +03:00
Qasim Umar
7665ba5e25 Add unit tests for factorial.py (#12815)
* Add unit tests for factorial.py

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

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

* uvx --python=3.12 unittest2pytest --write test_factorial.py

* Update error message in current_stock_price.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>
2025-07-05 12:58:45 +02:00
Mindaugas
c3d4b9e54d Add doctests for the boyer_moore_search algorithm. (#12769)
* Add doctests for the boyer_moore_search algorithm.

* Update boyer_moore_search.py

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

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

* Update boyer_moore_search.py

* Update boyer_moore_search.py

---------

Co-authored-by: Maxim Smolskiy <mithridatus@mail.ru>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2025-06-02 20:32:47 +03:00
JEONGHYUN MIN
4b077c06b6 feat: create straight_line_depreciation (#12377)
Co-authored-by: Jeonghyun Min <20122791@tafe.wa.edu.au>
2025-05-31 17:11:46 -04:00
Christian Clauss
d0d7f0b18a maths/radix2_fft.py: Fix calculation for Python 3.14 (#12772)
* maths/radix2_fft.py: Fix calculation for Python 3.14

As suggested at:
* https://github.com/TheAlgorithms/Python/issues/12729#issuecomment-2878608477
* https://github.com/TheAlgorithms/Python/pull/12710#discussion_r2080117333

@MaximSmolskiy @KirilBangachev @skirpichev Careful review, please.  I am just implementing the suggestion, but I do not have any expertise in this area.

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

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

* Change test results

* GitHub Actions: Rename job from build to directory_writer

It is confusing to have two jobs named `build`.

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2025-05-29 02:56:25 -04:00
pre-commit-ci[bot]
e26c388af0 [pre-commit.ci] pre-commit autoupdate (#12760)
* [pre-commit.ci] pre-commit autoupdate

updates:
- [github.com/astral-sh/ruff-pre-commit: v0.11.9 → v0.11.11](https://github.com/astral-sh/ruff-pre-commit/compare/v0.11.9...v0.11.11)
- [github.com/tox-dev/pyproject-fmt: v2.5.1 → v2.6.0](https://github.com/tox-dev/pyproject-fmt/compare/v2.5.1...v2.6.0)

* updating DIRECTORY.md

---------

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>
2025-05-26 22:55:55 +02:00
Mindaugas
a8ad2db2b9 Update matrix_chain_order calculation with more details and test. (#12759) 2025-05-23 00:17:48 +03:00
Mindaugas
e1115b5f15 Add tests and cleanup sum_of_subsets algorithm (#12746)
* Add tests and cleanup sum_of_subsets algorithm.

* Update sum_of_subsets.py

* Update sum_of_subsets.py

* Update sum_of_subsets.py

* Update sum_of_subsets.py

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

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

---------

Co-authored-by: Maxim Smolskiy <mithridatus@mail.ru>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2025-05-23 00:07:43 +03:00
Isidro
c81cc26996 Improve hash map (#12678)
* Mutable _Item

* document falsy item

* resize_down: expected test result

* resize_down: actual result

This is a problem since it causes rapid cycling

* improve comment about falsy item

Co-authored-by: Andrey <Cjkjvfnby@gmail.com>

* fix long line

* Update hash_map.py

* Update hash_map.py

---------

Co-authored-by: Andrey <Cjkjvfnby@gmail.com>
Co-authored-by: Maxim Smolskiy <mithridatus@mail.ru>
2025-05-22 23:44:25 +03:00
Prajwal Choudhari
ca445f5296 Add bidirectional search algorithm implementation (#12649)
* Add bidirectional search algorithm implementation

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

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

* Fix style and linting issues in bidirectional search

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

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

* Add doctest for main function

* Add doctest for main function

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

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

* fixed deprications

* fixed deprications

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

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

* removed unused import

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

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

* Update bidirectional_search.py

* Update bidirectional_search.py

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

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

* Update bidirectional_search.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: Maxim Smolskiy <mithridatus@mail.ru>
2025-05-22 18:08:37 +03:00
Isidro
26ad6891d8 Add median() function using Quickselect (#12676)
* Add median() function using Quickselect

* Update quick_select.py

* Update quick_select.py

* Update quick_select.py

---------

Co-authored-by: Maxim Smolskiy <mithridatus@mail.ru>
2025-05-21 21:33:29 +03:00
Christian Clauss
a2fa32c7ad Lukazlim: Replace dependency requests with httpx (#12744)
* Replace dependency `requests` with `httpx`

Fixes #12742
Signed-off-by: Lim, Lukaz Wei Hwang <lukaz.wei.hwang.lim@intel.com>

* updating DIRECTORY.md

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

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

---------

Signed-off-by: Lim, Lukaz Wei Hwang <lukaz.wei.hwang.lim@intel.com>
Co-authored-by: Lim, Lukaz Wei Hwang <lukaz.wei.hwang.lim@intel.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>
2025-05-14 04:42:11 +03:00
S Sajeev
6e4d1b3765 Physics orbital_transfer_work (#12728)
* Added iterative solution for power calculation

* Added iterative solution for power calculation

* Added iterative solution for power calculation

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

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

* Added iterative solution for power calculation fixes #12709

* Added iterative solution for power calculation  FIXES NUMBER 12709

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

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

* Escape velocity is the minimum speed an object must have to break free from a celestial body's gravitational pull without further propulsion.
Takes input as the Mass of the Celestial body (M) and Radius fron the center of mass (M)

* Fix: added header comment to escape_velocity.py

* Trigger re-PR with a minor change

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

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

* Fix: resolve Ruff linter errors and add Wikipedia reference

* Add: work done calculation for orbital transfer between orbits

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

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

* Update escape_velocity.py

* Delete maths/power_using_iteration.py

* Update and rename workdone.py to orbital_transfer_work.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>
2025-05-13 11:14:05 +02:00
pre-commit-ci[bot]
ee3a1732e0 [pre-commit.ci] pre-commit autoupdate (#12736)
updates:
- [github.com/astral-sh/ruff-pre-commit: v0.11.8 → v0.11.9](https://github.com/astral-sh/ruff-pre-commit/compare/v0.11.8...v0.11.9)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2025-05-12 19:59:33 +02:00