Commit Graph

174 Commits

Author SHA1 Message Date
Maxim Smolskiy
da47d5c88c
Enable ruff N999 rule (#11331)
* Enable ruff N999 rule

* updating DIRECTORY.md

---------

Co-authored-by: MaximSmolskiy <MaximSmolskiy@users.noreply.github.com>
2024-03-28 18:26:41 +01:00
Maxim Smolskiy
a936e94704
Enable ruff ARG001 rule (#11321)
* Enable ruff ARG001 rule

* Fix dynamic_programming/combination_sum_iv.py

* Fix machine_learning/frequent_pattern_growth.py

* Fix other/davis_putnam_logemann_loveland.py

* Fix other/password.py

* Fix

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

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

* Fix physics/n_body_simulation.py

* Fix project_euler/problem_145/sol1.py

* Fix project_euler/problem_174/sol1.py

* Fix scheduling/highest_response_ratio_next.py

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

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

* Fix

* Fix

* Fix scheduling/job_sequencing_with_deadline.py

* Fix scheduling/job_sequencing_with_deadline.py

* Fix

* Fix

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2024-03-20 15:00:17 +01:00
pre-commit-ci[bot]
bc8df6de31
[pre-commit.ci] pre-commit autoupdate (#11322)
* [pre-commit.ci] pre-commit autoupdate

updates:
- [github.com/astral-sh/ruff-pre-commit: v0.2.2 → v0.3.2](https://github.com/astral-sh/ruff-pre-commit/compare/v0.2.2...v0.3.2)
- [github.com/pre-commit/mirrors-mypy: v1.8.0 → v1.9.0](https://github.com/pre-commit/mirrors-mypy/compare/v1.8.0...v1.9.0)

* [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>
2024-03-13 07:52:41 +01:00
Maxim Smolskiy
fd27953d44
Reenable files when TensorFlow supports the current Python (#11318)
* Remove python_version < '3.12' for tensorflow

* Reenable dynamic_programming/k_means_clustering_tensorflow.py

* updating DIRECTORY.md

* Try to fix ruff

* Try to fix ruff

* Try to fix ruff

* Try to fix ruff

* Try to fix ruff

* Reenable machine_learning/lstm/lstm_prediction.py

* updating DIRECTORY.md

* Try to fix ruff

* Reenable computer_vision/cnn_classification.py

* updating DIRECTORY.md

* Reenable neural_network/input_data.py

* updating DIRECTORY.md

* Try to fix ruff

* Try to fix ruff

* Try to fix mypy

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

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

* Try to fix ruff

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

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

---------

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>
2024-03-12 09:35:49 +01:00
dahhou ilyas
eafdb8b866
Dahhou ilyas (#10058)
* add new programme in dynamique programming wildcard_matching

* add new programme in dynamique programming wildcard_matching

* fix bug

* fix

* fix

* fix

* fix

* fix

* fix error recrusion

* fix error recrusion

* bug fix

* add doctest

* The power of enumerate()

---------

Co-authored-by: Christian Clauss <cclauss@me.com>
2023-10-29 18:24:37 +01:00
hollowcrust
e9b3f20cec
Delete dynamic_programming/longest_sub_array.py (#10073) 2023-10-16 04:03:16 -04:00
Pooja Sharma
e6aae1cf66
Dynamic programming/matrix chain multiplication (#10562)
* updating DIRECTORY.md

* spell changes

* updating DIRECTORY.md

* real world applications

* updating DIRECTORY.md

* Update matrix_chain_multiplication.py

Add a non-dp solution with benchmarks.

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

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

* Update matrix_chain_multiplication.py

* Update matrix_chain_multiplication.py

* Update matrix_chain_multiplication.py

---------

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Co-authored-by: Pooja Sharma <poojasharma@MyBigMac.local>
Co-authored-by: Christian Clauss <cclauss@me.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2023-10-16 01:32:45 +02:00
Aasheesh
902278f656
Changes the code To return the list in dynamic_programming/subset_generation.py (#10191)
* Changing the code to return tuple

* Changing the code to return tuple

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

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

* Update dynamic_programming/subset_generation.py

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

* Adding doctests in subset_generation.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

* [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

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

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

* Update dynamic_programming/subset_generation.py

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

* 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

* [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 subset_generation.py

* Update subset_generation.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>
2023-10-15 21:56:02 +02:00
Kosuri L Indu
89d12dfe99
[Add] : Wildcard Matching program under DYNAMIC PROGRAMMING (#10403)
* To add wildcard_matching.py

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

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

* changes for doctest errors

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

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

* code changes

* [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>
2023-10-15 21:27:47 +02:00
SalmanSi
d96029e13d
added doctests for dynamicprogramming/minimum_partition (#10033)
* added doctests

* added doctests

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

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

* Add doctests to integer_partition.py

* Update minimum_partition.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>
2023-10-13 19:48:31 +02:00
dimonalik
1b4c4e7db2
Made problem explanation more clear (#9841)
* Update minimum_steps_to_one.py

Made the problem explanation more clear and readable

* updating DIRECTORY.md

* Apply suggestions from code review

---------

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Co-authored-by: Tianyi Zheng <tianyizheng02@gmail.com>
2023-10-10 00:34:36 -04:00
hollowcrust
fa077e6703
Add doctests, type hints; fix bug for dynamic_programming/minimum_partition.py (#10012)
* Add doctests, type hints; fix bug

* [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>
2023-10-08 10:58:48 +02:00
pre-commit-ci[bot]
895dffb412
[pre-commit.ci] pre-commit autoupdate (#9543)
* [pre-commit.ci] pre-commit autoupdate

updates:
- [github.com/astral-sh/ruff-pre-commit: v0.0.291 → v0.0.292](https://github.com/astral-sh/ruff-pre-commit/compare/v0.0.291...v0.0.292)
- [github.com/codespell-project/codespell: v2.2.5 → v2.2.6](https://github.com/codespell-project/codespell/compare/v2.2.5...v2.2.6)
- [github.com/tox-dev/pyproject-fmt: 1.1.0 → 1.2.0](https://github.com/tox-dev/pyproject-fmt/compare/1.1.0...1.2.0)

* updating DIRECTORY.md

* Fix typos in test_min_spanning_tree_prim.py

* Fix typos

* codespell --ignore-words-list=manuel

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Co-authored-by: Tianyi Zheng <tianyizheng02@gmail.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
2023-10-07 21:32:28 +02:00
Kosuri L Indu
60291738d2
add : trapped water program under dynamic programming (#10027)
* to add the trapped water program

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

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

* to make changes for error : B006

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

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

* to make changes for error : B006

* to make changes for error : B006

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

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

* to make changes in doctest

* to make changes in doctest

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

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

* Update dynamic_programming/trapped_water.py

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

* Update dynamic_programming/trapped_water.py

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

* to make changes in parameters

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

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

* to make changes in parameters

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

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

* Update dynamic_programming/trapped_water.py

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

* to make changes in parameters

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

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

* for negative heights

* Update dynamic_programming/trapped_water.py

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

* to remove falsy

* Final edits

* tuple[int, ...]

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
2023-10-07 21:08:38 +02:00
Parth
87494f1fa1
largest divisible subset (#9825)
* largest divisible subset

* minor tweaks

* adding more test cases

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

* improving code for better readability

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

* update

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

* update

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

* suggested changes done, and further modfications

* final update

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

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

* Update largest_divisible_subset.py

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

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

* Update largest_divisible_subset.py

---------

Co-authored-by: Christian Clauss <cclauss@me.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2023-10-05 18:21:28 +02:00
Sanket Kittad
1fda96b704
Palindromic (#9288)
* added longest palindromic subsequence

* removed

* added longest palindromic subsequence

* added longest palindromic subsequence link

* added comments
2023-10-05 12:40:14 +13:00
Christian Clauss
0f4e51245f
Upgrade to Python 3.12 (#9576)
* DRAFT: GitHub Actions: Test on Python 3.12

Repeats #8777
* #8777 

Some of our dependencies will not be ready yet.

* Python 3.12: Disable qiskit and tensorflow algorithms

* updating DIRECTORY.md

---------

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2023-10-03 14:47:10 +05:30
Belhadj Ahmed Walid
467903aa33
added smith waterman algorithm (#9001)
* added smith waterman algorithm

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

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

* descriptive names for the parameters a and b

* doctesting lowercase upcase empty string cases

* updated block quot,fixed traceback and doctests

* shorter block quote

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

* global vars to func params,more doctests

* updated doctests

* user access to SW params

* formating

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Tianyi Zheng <tianyizheng02@gmail.com>
2023-09-30 00:33:13 -04:00
pre-commit-ci[bot]
421ace81ed
[pre-commit.ci] pre-commit autoupdate (#9013)
* [pre-commit.ci] pre-commit autoupdate

updates:
- [github.com/astral-sh/ruff-pre-commit: v0.0.285 → v0.0.286](https://github.com/astral-sh/ruff-pre-commit/compare/v0.0.285...v0.0.286)
- [github.com/tox-dev/pyproject-fmt: 0.13.1 → 1.1.0](https://github.com/tox-dev/pyproject-fmt/compare/0.13.1...1.1.0)

* updating DIRECTORY.md

* Fis ruff rules PIE808,PLR1714

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
2023-08-29 15:18:10 +02:00
Ajinkya Chikhale
02d89bde67
Added implementation for Tribonacci sequence using dp (#6356)
* Added implementation for Tribonacci sequence using dp

* Updated parameter name

* Apply suggestions from code review

---------

Co-authored-by: Tianyi Zheng <tianyizheng02@gmail.com>
2023-08-14 00:12:42 -07:00
Amir Hosseini
f24ab2c60d
Add: Two Regex match algorithm (Recursive & DP) (#6321)
* Add recursive solution to regex_match.py

* Add dp solution to regex_match.py

* Add link to regex_match.py

* Minor edit

* Minor change

* Minor change

* Update dynamic_programming/regex_match.py

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

* Update dynamic_programming/regex_match.py

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

* Fix ruff formatting in if statements

* Update dynamic_programming/regex_match.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

---------

Co-authored-by: Tianyi Zheng <tianyizheng02@gmail.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2023-08-13 22:37:41 -07:00
Tianyi Zheng
a0eec90466
Consolidate duplicate implementations of max subarray (#8849)
* Remove max subarray sum duplicate implementations

* updating DIRECTORY.md

* Rename max_sum_contiguous_subsequence.py

* Fix typo in dynamic_programming/max_subarray_sum.py

* Remove duplicate divide and conquer max subarray

* updating DIRECTORY.md

---------

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2023-07-11 11:44:12 +02:00
Christian Clauss
4b79d771cd
Add more ruff rules (#8767)
* Add more ruff rules

* Add more ruff rules

* pre-commit: Update ruff v0.0.269 -> v0.0.270

* Apply suggestions from code review

* Fix doctest

* Fix doctest (ignore whitespace)

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

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

---------

Co-authored-by: Dhruv Manilawala <dhruvmanila@gmail.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2023-05-26 09:34:17 +02:00
Caeden Perelli-Harris
1faf10b5c2
Correct ruff failures (#8732)
* fix: Correct ruff problems

* updating DIRECTORY.md

* fix: Fix pre-commit errors

* updating DIRECTORY.md

---------

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2023-05-14 22:03:13 +01:00
Rohan Anand
458debc237
added a problem with solution on sliding window. (#8566)
* added a problem with solution on sliding window.

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

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

* added hint for return type and parameter

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

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

* Update minimum_size_subarray_sum.py

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

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

* Update minimum_size_subarray_sum.py

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

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

* Update minimum_size_subarray_sum.py

* Update minimum_size_subarray_sum.py

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

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

* Update minimum_size_subarray_sum.py

* removed un-necessary docs and added 2 test cases

* Rename sliding_window/minimum_size_subarray_sum.py to dynamic_programming/minimum_size_subarray_sum.py

* Update minimum_size_subarray_sum.py

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

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

* Update minimum_size_subarray_sum.py

* Update minimum_size_subarray_sum.py

* Update minimum_size_subarray_sum.py

* Update minimum_size_subarray_sum.py

* Update minimum_size_subarray_sum.py

* Update minimum_size_subarray_sum.py

* Update dynamic_programming/minimum_size_subarray_sum.py

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

* Update dynamic_programming/minimum_size_subarray_sum.py

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

* Update dynamic_programming/minimum_size_subarray_sum.py

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

* Update dynamic_programming/minimum_size_subarray_sum.py

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

* Update dynamic_programming/minimum_size_subarray_sum.py

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

* Update dynamic_programming/minimum_size_subarray_sum.py

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

* Update dynamic_programming/minimum_size_subarray_sum.py

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

* Update minimum_size_subarray_sum.py

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

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

* Fix

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

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

* Update minimum_size_subarray_sum.py

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

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

* Update minimum_size_subarray_sum.py

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

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

* Update minimum_size_subarray_sum.py

* Update minimum_size_subarray_sum.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>
2023-04-18 10:02:20 +02:00
Maxim Smolskiy
56a40eb3ee
Reenable files when TensorFlow supports the current Python (#8602)
* Remove python_version < "3.11" for tensorflow

* Reenable neural_network/input_data.py_tf

* updating DIRECTORY.md

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

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

* Try to fix ruff

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

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

* Try to fix ruff

* Try to fix ruff

* Try to fix ruff

* Try to fix pre-commit

* Try to fix

* Fix

* Fix

* Reenable dynamic_programming/k_means_clustering_tensorflow.py_tf

* updating DIRECTORY.md

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

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

* Try to fix ruff

---------

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2023-04-01 19:43:11 +02:00
Rohan Anand
a00492911a
added a problem on kadane's algo and its solution. (#8569)
* added kadane's algorithm directory with one problem's solution.

* added type hints

* Rename kaadne_algorithm/max_product_subarray.py to dynamic_programming/max_product_subarray.py

* Update dynamic_programming/max_product_subarray.py

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

* Update max_product_subarray.py

* Update max_product_subarray.py

* Update dynamic_programming/max_product_subarray.py

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

* Update max_product_subarray.py

* Update max_product_subarray.py

* Update max_product_subarray.py

* Update max_product_subarray.py

* Update max_product_subarray.py

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

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

* Update max_product_subarray.py

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

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

* Update max_product_subarray.py

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

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

* Update max_product_subarray.py

* Update max_product_subarray.py

* Update dynamic_programming/max_product_subarray.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 dynamic_programming/max_product_subarray.py

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

* Update max_product_subarray.py

---------

Co-authored-by: Christian Clauss <cclauss@me.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2023-03-31 13:17:13 +02:00
Christian Clauss
c96241b5a5
Replace bandit, flake8, isort, and pyupgrade with ruff (#8178)
* Replace bandit, flake8, isort, and pyupgrade with ruff

* Comment on ruff rules

* updating DIRECTORY.md

---------

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2023-03-15 13:58:25 +01:00
Christian Clauss
64543faa98
Make some ruff fixes (#8154)
* Make some ruff fixes

* Undo manual fix

* Undo manual fix

* Updates from ruff=0.0.251
2023-03-01 17:23:33 +01:00
Christian Clauss
c909da9b08
pre-commit: Upgrade psf/black for stable style 2023 (#8110)
* pre-commit: Upgrade psf/black for stable style 2023

Updating https://github.com/psf/black ... updating 22.12.0 -> 23.1.0 for their `2023 stable style`.
* https://github.com/psf/black/blob/main/CHANGES.md#2310

> This is the first [psf/black] release of 2023, and following our stability policy, it comes with a number of improvements to our stable style…

Also, add https://github.com/tox-dev/pyproject-fmt and https://github.com/abravalheri/validate-pyproject to pre-commit.

I only modified `.pre-commit-config.yaml` and all other files were modified by pre-commit.ci and psf/black.

* [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>
2023-02-01 18:44:54 +05:30
Alexander Pantyukhin
c6223c71d8
add word_break dynamic approach up -> down. (#8039)
* add word_break dynamic approach up -> down.

* updating DIRECTORY.md

* Update word_break.py

fix review notes.

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

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

* Update word_break.py

fix review notes

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

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

* fix review notes

* add trie type

* Update word_break.py

add typing Any to trie.

* Update dynamic_programming/word_break.py

Co-authored-by: Caeden Perelli-Harris <caedenperelliharris@gmail.com>

* Update dynamic_programming/word_break.py

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

* Update dynamic_programming/word_break.py

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

* Update dynamic_programming/word_break.py

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

* Update dynamic_programming/word_break.py

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

* fix review notes

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Caeden Perelli-Harris <caedenperelliharris@gmail.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
2022-12-30 06:47:40 +01:00
Mark Mayo
f32d611689
clean of unnecessary checks, imports, calls (#7993) 2022-11-21 00:00:27 +13:00
Caeden Perelli-Harris
598f6a26a1
refactor: Condense password related files in one (#7939)
* refactor: Condense `password` related files in one

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

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

* Update other/password.py

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

* dynamic_programming

* test: Make test input `str`

* requirements.txt: Remove cython>=0.29.28  # For statsmodels on Python 3.11

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
2022-11-02 17:20:57 +01:00
Alexander Pantyukhin
f05baa2b2b
add dp up - down minimum cost for tickets (#7934)
* add dp up - down minimum cost for tickets

* add typints

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

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

* add new tests and checks.

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

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

* add more tests

* add types for the dp function

* Update dynamic_programming/minimum_tickets_cost.py

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

* fix review notes

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

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

* small fix

* Update dynamic_programming/minimum_tickets_cost.py

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

* Update dynamic_programming/minimum_tickets_cost.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

* fix tests

* Update dynamic_programming/minimum_tickets_cost.py

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

* Update dynamic_programming/minimum_tickets_cost.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>
2022-11-02 13:25:19 +01:00
Tianyi Zheng
39e5bc5980
Refactor bottom-up edit distance function to be class method (#7347)
* Refactor bottom-up function to be class method

* Add type hints

* Update convolve function namespace

* Remove depreciated np.float

* updating DIRECTORY.md

* updating DIRECTORY.md

* updating DIRECTORY.md

* updating DIRECTORY.md

* Renamed function for consistency

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Co-authored-by: Chris O <46587501+ChrisO345@users.noreply.github.com>
2022-10-31 18:13:21 +13:00
Agniv Ghosh
47100b992a
Added code for palindrome partitioning problem under dynamic programming (#7222)
* Added code for palindrome partitioning problem under dynamic programming

* Updated return type for function

* Updated Line 24 according to suggestions

* Apply suggestions from code review

Co-authored-by: Caeden Perelli-Harris <caedenperelliharris@gmail.com>

* Update palindrome_partitioning.py

* Update palindrome_partitioning.py

* is_palindromic

Co-authored-by: Christian Clauss <cclauss@me.com>
Co-authored-by: Caeden Perelli-Harris <caedenperelliharris@gmail.com>
2022-10-30 14:15:46 +01:00
Alexander Pantyukhin
cf915e7042
add Levinstein distance with Dynamic Programming: up -> down approach (#7171)
* add Levinstein distance with Dynamic Programming: up -> down approach

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

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

* add type hint

* fix flake8

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

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

* Update dynamic_programming/min_distance_up_bottom.py

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

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

* Update min_distance_up_bottom.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>
2022-10-30 14:00:16 +01:00
giladwo
00dfad9d20
Simplify climbing stairs and use constant memory (#6628)
* Simplify climbing stairs and use constant memory

* number_of_steps

Co-authored-by: Christian Clauss <cclauss@me.com>
2022-10-30 10:59:10 +01:00
lostybtw
f87de60b6d
fizzbuzz complete (#6504)
* fizzbuzz

* Update dynamic_programming/fizz_buzz.py

Co-authored-by: Caeden <caedenperelliharris@gmail.com>

* Update dynamic_programming/fizz_buzz.py

Co-authored-by: Caeden <caedenperelliharris@gmail.com>

* Update dynamic_programming/fizz_buzz.py

Co-authored-by: Caeden <caedenperelliharris@gmail.com>

* Update dynamic_programming/fizz_buzz.py

Co-authored-by: Caeden <caedenperelliharris@gmail.com>

* Update dynamic_programming/fizz_buzz.py

Co-authored-by: Caeden <caedenperelliharris@gmail.com>

* added doctests and function to fizzbuzz

* Update fizz_buzz.py

* Update fizz_buzz.py

* Fixed FizzBuzz

* fizzbuzz passing test

* Update dynamic_programming/fizz_buzz.py

Co-authored-by: Caeden <caedenperelliharris@gmail.com>

* Update dynamic_programming/fizz_buzz.py

Co-authored-by: Caeden <caedenperelliharris@gmail.com>

* Update dynamic_programming/fizz_buzz.py

Co-authored-by: Caeden <caedenperelliharris@gmail.com>

* Update dynamic_programming/fizz_buzz.py

Co-authored-by: Caeden <caedenperelliharris@gmail.com>

* Update fizz_buzz.py

* Update fizz_buzz.py

* Update fizz_buzz.py

* fixed fizzbuzz

* Add files via upload

* added mechanical energy calculation

* Delete mechanical_energy.py

* Update fizz_buzz.py

* Update dynamic_programming/fizz_buzz.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 fizz_buzz.py

Co-authored-by: Caeden <caedenperelliharris@gmail.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>
2022-10-30 08:22:52 +01:00
Carlos Villar
7b521b66cf
Add Viterbi algorithm (#7509)
* Added Viterbi algorithm Fixes: #7465

Squashed commits

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

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

* Added doctest for validators

* moved all extracted functions to the main function

* Forgot a type hint

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2022-10-29 15:44:18 +02:00
Shubham Kondekar
fe5819c872
Create combination_sum_iv.py (#7672)
* Create combination_sum_iv.py

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

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

* Update dynamic_programming/combination_sum_iv.py

Co-authored-by: Caeden Perelli-Harris <caedenperelliharris@gmail.com>

* Update dynamic_programming/combination_sum_iv.py

Co-authored-by: Caeden Perelli-Harris <caedenperelliharris@gmail.com>

* Update dynamic_programming/combination_sum_iv.py

Co-authored-by: Caeden Perelli-Harris <caedenperelliharris@gmail.com>

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

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

* Update combination_sum_iv.py

* Update combination_sum_iv.py

* Resolved PR Comments

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

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

* minor change, argument missing in function

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

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

* Update dynamic_programming/combination_sum_iv.py

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

* minor change

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Caeden Perelli-Harris <caedenperelliharris@gmail.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
2022-10-28 21:32:32 +02:00
Christian Clauss
19bff003aa
Adopt Python >= 3.8 assignment expressions using auto-walrus (#7737)
* Adopt Python >= 3.8 assignment expressions using auto-walrus

* updating DIRECTORY.md

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

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

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2022-10-28 15:54:54 +02:00
Caeden Perelli-Harris
9bba42eca8
refactor: Indent ... for visual purposes (#7744) 2022-10-27 19:42:30 +02:00
JatinR05
8fd06efe22
Create minimums_squares_to_represent_a_number.py (#7595)
* Create minimums_squares_to_represent_a_number.py

added a dynamic programming approach of finding the minimum number of square to represent a number.
eg : 
25 = 5*5
37 = 6*6 + 1*1
21 = 4*4 + 2*2 + 1*1

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

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

* Update and rename minimums_squares_to_represent_a_number.py to minimum_squares_to_represent_a_number.py

updated the code

* Update minimum_squares_to_represent_a_number.py

I have added the appropriate checks for 0 and 12.34. 
It would be great if you could suggest a name for the dp array

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

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

* Update minimum_squares_to_represent_a_number.py

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

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

* Update minimum_squares_to_represent_a_number.py

updated

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

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

* Update minimum_squares_to_represent_a_number.py

updated

* [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>
2022-10-26 16:43:01 +02:00
RohitSingh107
c31ef5e778
Add longest common substring (#7488)
* added longest common substring

* added retrun type hint

* Update dynamic_programming/longest_common_substring.py

Co-authored-by: Caeden Perelli-Harris <caedenperelliharris@gmail.com>

* Update dynamic_programming/longest_common_substring.py

Co-authored-by: Caeden Perelli-Harris <caedenperelliharris@gmail.com>

* Update dynamic_programming/longest_common_substring.py

Co-authored-by: Caeden Perelli-Harris <caedenperelliharris@gmail.com>

* Update dynamic_programming/longest_common_substring.py

Co-authored-by: Caeden Perelli-Harris <caedenperelliharris@gmail.com>

* Update dynamic_programming/longest_common_substring.py

Co-authored-by: Caeden Perelli-Harris <caedenperelliharris@gmail.com>

* Update dynamic_programming/longest_common_substring.py

Co-authored-by: Caeden Perelli-Harris <caedenperelliharris@gmail.com>

* Update dynamic_programming/longest_common_substring.py

Co-authored-by: Caeden Perelli-Harris <caedenperelliharris@gmail.com>

* Update dynamic_programming/longest_common_substring.py

Co-authored-by: Caeden Perelli-Harris <caedenperelliharris@gmail.com>

* Update dynamic_programming/longest_common_substring.py

Co-authored-by: Caeden Perelli-Harris <caedenperelliharris@gmail.com>

* Update dynamic_programming/longest_common_substring.py

Co-authored-by: Caeden Perelli-Harris <caedenperelliharris@gmail.com>

* Update dynamic_programming/longest_common_substring.py

Co-authored-by: Caeden Perelli-Harris <caedenperelliharris@gmail.com>

* changed t1, t2 to text1, text2

* Update longest_common_substring.py

* Update dynamic_programming/longest_common_substring.py

Co-authored-by: Chris O <46587501+ChrisO345@users.noreply.github.com>

* Update dynamic_programming/longest_common_substring.py

Co-authored-by: Chris O <46587501+ChrisO345@users.noreply.github.com>

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

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

* applied suggested changes

* Update dynamic_programming/longest_common_substring.py

Co-authored-by: Caeden Perelli-Harris <caedenperelliharris@gmail.com>

* removed space between line

* return longest common substring

* Update dynamic_programming/longest_common_substring.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

Co-authored-by: Caeden Perelli-Harris <caedenperelliharris@gmail.com>
Co-authored-by: Chris O <46587501+ChrisO345@users.noreply.github.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>
2022-10-25 22:55:48 +01:00
Nadirhan Şahin
e2a83b3bc6
Update knapsack.py (#7271)
* Update knapsack.py

* Update dynamic_programming/knapsack.py

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

* Update knapsack.py

* [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>
2022-10-23 21:28:11 +02:00
Tianyi Zheng
cc10b20beb
Remove some print statements within algorithmic functions (#7499)
* Remove commented-out print statements in algorithmic functions

* Encapsulate non-algorithmic code in __main__

* Remove unused print_matrix function

* Remove print statement in __init__

* Remove print statement from doctest

* Encapsulate non-algorithmic code in __main__

* Modify algorithm to return instead of print

* Encapsulate non-algorithmic code in __main__

* Refactor data_safety_checker to return instead of print

* updating DIRECTORY.md

* updating DIRECTORY.md

* Apply suggestions from code review

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

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

Co-authored-by: github-actions <${GITHUB_ACTOR}@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>
2022-10-22 13:33:51 +02:00
Caeden Perelli-Harris
f15cc2f01c
Follow Flake8 pep3101 and remove modulo formatting (#7339)
* ci: Add ``flake8-pep3101`` plugin to ``pre-commit``

* refactor: Remove all modulo string formatting

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

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

* refactor: Remove ``flake8-pep3101`` plugin from ``pre-commit``

* revert: Revert to modulo formatting

* refactor: Use f-string instead of `join`

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2022-10-16 22:50:11 +02:00
SudhanshuSuman
7f6e0b656f
Corrected the directory of Fractional Knapsack algorithm (#7086)
* Moved fractional knapsack from 'dynamic_programming' to 'greedy_methods'

* Updated DIRECTORY.md
2022-10-16 22:41:28 +02:00
Caeden
a652905b60
Add Flake8 comprehensions to pre-commit (#7235)
* ci(pre-commit): Add ``flake8-comprehensions`` to ``pre-commit`` (#7233)

* refactor: Fix ``flake8-comprehensions`` errors

* fix: Replace `map` with generator (#7233)

* fix: Cast `range` objects to `list`
2022-10-15 19:29:42 +02:00