Commit Graph

152 Commits

Author SHA1 Message Date
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
Caeden
4d0c830d2c
Add flake8 pluin flake8 bugbear to pre-commit (#7132)
* ci(pre-commit): Add ``flake8-builtins`` additional dependency to ``pre-commit`` (#7104)

* refactor: Fix ``flake8-builtins`` (#7104)

* fix(lru_cache): Fix naming conventions in docstrings (#7104)

* ci(pre-commit): Order additional dependencies alphabetically (#7104)

* fix(lfu_cache): Correct function name in docstring (#7104)

* Update strings/snake_case_to_camel_pascal_case.py

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

* Update data_structures/stacks/next_greater_element.py

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

* Update digital_image_processing/index_calculation.py

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

* Update graphs/prim.py

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

* Update hashes/djb2.py

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

* refactor: Rename `_builtin` to `builtin_` ( #7104)

* fix: Rename all instances (#7104)

* refactor: Update variable names (#7104)

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

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

* ci: Create ``tox.ini`` and ignore ``A003`` (#7123)

* revert: Remove function name changes (#7104)

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

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

* Rename tox.ini to .flake8

* Update data_structures/heap/heap.py

Co-authored-by: Dhruv Manilawala <dhruvmanila@gmail.com>

* refactor: Rename `next_` to `next_item` (#7104)

* ci(pre-commit): Add `flake8` plugin `flake8-bugbear` (#7127)

* refactor: Follow `flake8-bugbear` plugin (#7127)

* fix: Correct `knapsack` code (#7127)

* [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>
Co-authored-by: Dhruv Manilawala <dhruvmanila@gmail.com>
2022-10-13 18:03:06 +02:00
Caeden
d5a9f649b8
Add flake8-builtins to pre-commit and fix errors (#7105)
Ignore `A003`

Co-authored-by: Christian Clauss <cclauss@me.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Dhruv Manilawala <dhruvmanila@gmail.com>
2022-10-13 19:53:59 +05:30
Caeden
07e991d553
Add pep8-naming to pre-commit hooks and fixes incorrect naming conventions (#7062)
* ci(pre-commit): Add pep8-naming to `pre-commit` hooks (#7038)

* refactor: Fix naming conventions (#7038)

* Update arithmetic_analysis/lu_decomposition.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

* refactor(lu_decomposition): Replace `NDArray` with `ArrayLike` (#7038)

* chore: Fix naming conventions in doctests (#7038)

* fix: Temporarily disable project euler problem 104 (#7069)

* chore: Fix naming conventions in doctests (#7038)

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-13 00:54:20 +02:00
Omkaar
dbee5f072f
Improve code on f-strings and brevity (#6126)
* Update strassen_matrix_multiplication.py

* Update matrix_operation.py

* Update enigma_machine2.py

* Update enigma_machine.py

* Update enigma_machine2.py

* Update rod_cutting.py

* Update external_sort.py

* Update sol1.py

* Update hill_cipher.py

* Update prime_numbers.py

* Update integration_by_simpson_approx.py
2022-05-13 20:51:44 +08:00
Sailesh Shrestha
3815a97575
Add all_construct dynamic programming implementation (#5626)
* Add all_construct dynamic programming implementation

* all_construct: remove the main function

* all_construct: Add type hints

* all_construct: changed map to list comprehension,fix mutable default arguments

* all_construct: fixed type hints

* all_construct: cleaner code for initializing word_bank argument

* all_construct: added an import for annotations

* all_construct: added None in the argument with word_bank

* all_construct: fixed a type hint

* all_construct: Fixed some more type hints
2021-11-04 16:18:38 +01:00
Maarten
868c2fa0a8
Rewrite fibonacci.py (#5665) (#5677)
* Removed doctest call

* Removed 0 and 1 append to `fib_array`

* Moved fibonacci sequence logic into `calculate`

* Refactored `get` to generate missing numbers

* Renamed `fib_array` to `sequence`

* Renamed `number` to `index`

* Refactored `get` to only return sequence to `index`

* Moved main block into function

* Added documentation to `get`

* Added missing type hints

* Fixed doctest error in `get` docstring

* Moved calculate logic into get

* Reformatted with black

* Fixed wrong generation range
2021-10-31 22:19:44 +08:00
imp
c1b15a86ba
[mypy] Fix type annotations for dynamic programming (#4687)
* Fix mypy error for knapsack.py

* Fix mypy error for longest_increasing_subsequence

* Fix mypy error for fractional_knapsack_2.py
2021-09-03 11:49:23 +02:00
Aswin Murali
3acca3d1d1
Fix type annotations for integer_partition.py #4052 (#4689) 2021-08-30 10:06:59 +02:00
Lakshay Akula
cb0a5480a7
Add catalan_numbers.py (#4455)
Reviewed by @mrmaxguns. This is an implementation of Catalan Numbers.
2021-05-31 19:55:01 -05:00
CarsonHam
61f3119467
Change occurrences of str.format to f-strings (#4118)
* f-string update rsa_cipher.py

* f-string update rsa_key_generator.py

* f-string update burrows_wheeler.py

* f-string update non_recursive_segment_tree.py

* f-string update red_black_tree.py

* f-string update deque_doubly.py

* f-string update climbing_stairs.py

* f-string update iterating_through_submasks.py

* f-string update knn_sklearn.py

* f-string update 3n_plus_1.py

* f-string update quadratic_equations_complex_numbers.py

* f-string update nth_fibonacci_using_matrix_exponentiation.py

* f-string update sherman_morrison.py

* f-string update levenshtein_distance.py

* fix lines that were too long
2021-02-23 11:23:49 +05:30
Kanak
677d48d6c0
Rename coin_change.py to minimum_coin_change.py (#4108) 2021-01-11 16:55:15 +05:30
Alex Joslin
e7ab06f5de
Implemented minimum steps to one using tabulation. (#3911)
* Implemented minimum steps to one using tabulation.

* Update minimum_steps_to_one.py

Made the parameter "n" more descriptive.  Changed it to number

* `n` to `number`

Co-authored-by: John Law <johnlaw.po@gmail.com>
2020-12-09 17:22:07 +08:00
Himadri Ganguly
46af42d47a
Fix coin change (#2571)
* Removed unused variable m.

* Doctests are modified to match functions.

* Added condition for negative values.

* Fixed white-space around operator.

* Fixed W293 blank line contains white-space error.

* Update dynamic_programming/coin_change.py

Co-authored-by: Tapajyoti Bose <44058757+ruppysuppy@users.noreply.github.com>

* Fixed error in code.

* Fixed whited spacing.

* Fixed PEP8 error.

* Added more test cases for coin change problem.

* Removed extra test for negetive value.

Co-authored-by: Tapajyoti Bose <44058757+ruppysuppy@users.noreply.github.com>
2020-10-24 00:55:13 +08:00
Dhruv
48357cea5b
Add __init__.py files in all the directories (#2503) 2020-09-28 19:42:36 +02:00
Christian Clauss
9200a2e543
from __future__ import annotations (#2464)
* from __future__ import annotations

* fixup! from __future__ import annotations

* fixup! from __future__ import annotations

* fixup! Format Python code with psf/black push

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-09-23 13:30:13 +02:00
Du Yuanchao
4d0a8f2355
Optimized recursive_bubble_sort (#2410)
* optimized recursive_bubble_sort

* Fixed doctest error due whitespace

* reduce loop times for optimization

* fixup! Format Python code with psf/black push

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-09-10 10:31:26 +02:00
Sanders Lin
f0d7879a11
fixed error in factorial.py (#1888)
* Update factorial.py

* updating DIRECTORY.md

* Update dynamic_programming/factorial.py

* Update factorial.py

Co-authored-by: mateuszz0000 <mtszzwdzk@gmail.com>
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
2020-08-05 13:18:41 +02:00
Christian Clauss
5f4da5d616
isort --profile black . (#2181)
* updating DIRECTORY.md

* isort --profile black .

* Black after

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-07-06 09:44:19 +02:00
Christian Clauss
cd3e8f95a0
isort --profile black --recursive . (#2170)
* isort --profile black --recursive .

* Update codespell.yml

* typo: vertices

* typo: Explanation

* typo: Explanation

* Fix typos
2020-07-06 08:48:18 +05:30
vinayak
2d3d660155
black fixes and Travis CI fixes (#2160)
* black format

* updating DIRECTORY.md

* fixes

* fixup! Format Python code with psf/black push

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-07-02 20:02:15 +05:30
Tapajyoti Bose
c534e77cb1
Added minimum cost path algorithm (#2135)
* Added maximum path sum for matrix (top left to bottom right)

* Changed maximum cost path to minimum cost path + added video explaination
2020-07-02 14:43:29 +05:30
Christian Clauss
fdc5bee7af
Euler problem 551 sol 1: Reduce McCabe code complexity (#2141)
* Euler problem 551 sol 1: Reduce McCabe code complexity

As discussed in #2128

* fixup! Format Python code with psf/black push

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-06-22 14:16:12 +02:00