Commit Graph

3300 Commits

Author SHA1 Message Date
Dean Bring
b9a797f3d4
Added the Minkowski distance function (#10143)
* Added the Minkowski distance function

* Made error handling more precise

* Added note about floating point errors and corresponding doctest
2023-10-09 19:00:37 -04:00
pre-commit-ci[bot]
53638fcec4
[pre-commit.ci] pre-commit autoupdate (#10197)
updates:
- [github.com/pre-commit/pre-commit-hooks: v4.4.0 → v4.5.0](https://github.com/pre-commit/pre-commit-hooks/compare/v4.4.0...v4.5.0)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2023-10-09 23:38:32 +02:00
Dean Bring
b0aa35c7b3
Added the Chebyshev distance function (#10144)
* Added the Chebyshev distance function

* Remove float cast and made error handling more precise
2023-10-09 17:21:46 -04:00
aryan1165
5d0a46814e
Added ciphers/permutation_cipher.py. (#9163)
* Added permutation_cipher.py

* Added type hints for parameters

* Added doctest in functions

* Update ciphers/permutation_cipher.py

Ya i felt the same but held back because there is a implementation of transposition_cipher.py. But that's is different from the one i have implemented here.

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

* Update ciphers/permutation_cipher.py

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

* Update ciphers/permutation_cipher.py

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

* Update ciphers/permutation_cipher.py

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

* Update ciphers/permutation_cipher.py

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

* Update ciphers/permutation_cipher.py

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

* Update ciphers/permutation_cipher.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

* Changes

---------

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-10-09 15:38:04 -04:00
Christian Clauss
844270c6e9
Remove backslashes from is_palindrome.py (#10169)
@SaiHarshaK Fixes https://github.com/TheAlgorithms/Python/pull/10081#discussion_r1349651289
2023-10-10 06:42:07 +13:00
Kamil
ba828fe621
test_digital_image_processing -> test_local_binary_pattern replacing a large image with a smaller one (#10161)
* Replacing the generator with numpy vector operations from lu_decomposition.

* Revert "Replacing the generator with numpy vector operations from lu_decomposition."

This reverts commit ad217c6616.

* Replaced lena.jpg with lena_small.jpg to make tests faster.

* Update digital_image_processing/test_digital_image_processing.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 test_digital_image_processing.py

tests fail, I'll try an empty commit

* Apply suggestions from code review

* Update test_digital_image_processing.py

added clarifications

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

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

* Update test_digital_image_processing.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>
Co-authored-by: Tianyi Zheng <tianyizheng02@gmail.com>
2023-10-09 17:46:38 +02:00
Sai Harsha Kottapalli
c0da015b7d
Add DocTests to diffie.py (#10156)
* diffie doctest

* fix ut

* update doctest

---------

Co-authored-by: Harsha Kottapalli <skottapalli@microsoft.com>
2023-10-09 17:19:05 +02:00
Kausthub Kannan
53d78b9cc0
Added Huber Loss Function (#10141) 2023-10-09 10:33:47 -04:00
Siddik Patel
583a614fef
Removed redundant greatest_common_divisor code (#9358)
* Deleted greatest_common_divisor def from many files and instead imported the method from Maths folder

* Deleted greatest_common_divisor def from many files and instead imported the method from Maths folder, also fixed comments

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

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

* Deleted greatest_common_divisor def from many files and instead imported the method from Maths folder, also fixed comments

* Imports organized

* recursive gcd function implementation rolledback

* more gcd duplicates removed

* more gcd duplicates removed

* Update maths/carmichael_number.py

* updated files

* moved a file to another location

---------

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-10-09 14:19:12 +02:00
Sai Harsha Kottapalli
876087be99
Add DocTests to magicdiamondpattern.py (#10135)
* magicdiamondpattern doctest

* remove start part

---------

Co-authored-by: Harsha Kottapalli <skottapalli@microsoft.com>
2023-10-09 14:16:43 +02:00
Sai Harsha Kottapalli
12e8e9ca87
Add DocTests to is_palindrome.py (#10081)
* add doctest ut

* test complete

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

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

* format

* ruff update

* cover line 154

* Update data_structures/linked_list/is_palindrome.py

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

* use dataclass

* pre-commit fix

* Fix mypy errors

* use future annotations

---------

Co-authored-by: Harsha Kottapalli <skottapalli@microsoft.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>
2023-10-09 14:06:16 +02:00
Saahil Mahato
ed19b1cf0c
Add binary step activation function (#10030)
* Add binary step activation function

* fix: ruff line too long error

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

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

* refactor: add link to directory

* revert: add link to directory

* fix: algorithm bug and docs

* Update neural_network/activation_functions/binary_step.py

* fix: ruff line too long error

---------

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-10-08 19:34:50 -04:00
Saahil Mahato
2260961a80
Add Soboleva Modified Hyberbolic Tangent function (#10043)
* Add Sobovela Modified Hyberbolic Tangent function

* fix: typo

* Update and rename sobovela_modified_hyperbolic_tangent.py to soboleva_modified_hyperbolic_tangent.py

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

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

* fix: typo

* Apply suggestions from code review

---------

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-10-08 19:19:28 -04:00
Megan Payne
a2b695dabd
Added Germain primes algorithm to the maths folder (#10120)
* Added algorithm for Germain Primes to maths folder

* Fixed test errors Germain primes.

* Formatting Germain primes after pre-commit

* Fixed path to maths

* Update maths/germain_primes.py

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

* Update maths/germain_primes.py

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

* Added function for safe primes

* Update maths/germain_primes.py

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

* Apply suggestions from code review

---------

Co-authored-by: Megan Payne <payneconsulting.nl@gmail.com>
Co-authored-by: Tianyi Zheng <tianyizheng02@gmail.com>
2023-10-08 17:33:50 -04:00
Anshu Sharma
66e4ea6a62
Consolidated two scripts reverse_letters.py and reverse_long_words.py into one (#10140)
* Conolidated two scripts reverse_letters.py and reverse_long_words.py into one because of similar functionality

* Added a new line to accomodate characters without going over 88 char limit

* fixed grammar to pass pre-commit

* Changed faulty test case entirely to pass pre commit

* fixed a test case which was wrong

---------

Co-authored-by: Keyboard-1 <142900182+Keyboard-1@users.noreply.github.com>
2023-10-09 09:17:22 +13:00
halfhearted
2d02500332
equilibrium index in an array (#9856)
* equilibrium index in an array

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

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

* equilibrium index in an array

* equilibrium index in an array

* equilibrium index in an array removed type in docstring

---------

Co-authored-by: ArunSiva <Arunsiva003@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2023-10-09 08:44:49 +13:00
Tianyi Zheng
8e108ed92a
Rename maths/binary_exponentiation_3.py (#9656)
* updating DIRECTORY.md

* Rename binary_exponentiation_3.py

Rename binary_exponentiation_3.py to binary_exponentiation_2.py because
the original binary_exponentiation_2.py was renamed to
binary_multiplication.py in PR #9513

* updating DIRECTORY.md

* updating DIRECTORY.md

* updating DIRECTORY.md

* updating DIRECTORY.md

---------

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2023-10-09 08:43:07 +13:00
Achal Jain
17de908d1a
Added Median of Medians Algorithm (#9864)
* Added Median of Medians Algorithm

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

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

* Update median_of_medians.py as per requested 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-09 08:41:30 +13:00
Siddharth Warrier
c8f6f79f80
Power of 4 (#9505)
* added power_of_4

* updated power_of_4

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

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

* updated power_of_4

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

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

* updated power_of_4

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

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

* updated power_of_4

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

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

* updated power_of_4

* added type check

* added tescase

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2023-10-09 08:40:14 +13:00
SubhranShu2332
e7a59bfff5
In place of calculating the factorial several times we can run a loop k times to calculate the combination (#10051)
* In place of calculating the factorial several times we can run a loop k times to calculate the combination 

for example:
5 C 3 = 5! / (3! * (5-3)! )
= (5*4*3*2*1)/[(3*2*1)*(2*1)]
=(5*4*3)/(3*2*1)
so running a loop k times will reduce the time complexity to O(k)

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

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

* Update maths/combinations.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: Tianyi Zheng <tianyizheng02@gmail.com>
2023-10-08 15:17:02 -04:00
Kosuri L Indu
982bc27358
add : Best time to buy and sell stock program under GREEDY methods (#10114)
* to add best_time_stock program

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

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

* Update best_time_to_buy_and_sell_stock.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-08 19:07:02 +02:00
Saurabh Mahapatra
e89ae55d8e
Create strip.py (#10011)
* Create strip.py

* Update strip.py
2023-10-08 12:10:41 -04:00
Kausthub Kannan
a12b07f352
Added Squareplus Activation Function (#9977)
* Added Squareplus Activation Function

* Added parameter beta to the function

* Fixed Squareplus Function

* Update neural_network/activation_functions/squareplus.py

---------

Co-authored-by: Tianyi Zheng <tianyizheng02@gmail.com>
2023-10-08 12:08:37 -04:00
Arnav Kohli
81b29066d2
Created folder for losses in Machine_Learning (#9969)
* Created folder for losses in Machine_Learning

* Update binary_cross_entropy.py

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

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

* Update mean_squared_error.py

* Update binary_cross_entropy.py

* Update mean_squared_error.py

* Update binary_cross_entropy.py

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

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

* Update mean_squared_error.py

* Update binary_cross_entropy.py

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

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

* Update mean_squared_error.py

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

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

* Update binary_cross_entropy.py

* Update mean_squared_error.py

* Update binary_cross_entropy.py

* Update mean_squared_error.py

* Update machine_learning/losses/binary_cross_entropy.py

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

* Update machine_learning/losses/mean_squared_error.py

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

* Update machine_learning/losses/binary_cross_entropy.py

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

* Update mean_squared_error.py

* Update machine_learning/losses/mean_squared_error.py

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

* Update binary_cross_entropy.py

* Update mean_squared_error.py

* Update binary_cross_entropy.py

* Update mean_squared_error.py

* Update mean_squared_error.py

* Update binary_cross_entropy.py

* renamed: losses -> loss_functions

* updated 2 files

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

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

* Update mean_squared_error.py

* Update mean_squared_error.py

* Update binary_cross_entropy.py

* Update mean_squared_error.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: Tianyi Zheng <tianyizheng02@gmail.com>
2023-10-08 12:04:43 -04:00
Aarya Balwadkar
6860daea60
Made Changes shifted CRT, modular division to maths directory (#10084) 2023-10-08 11:53:38 -04:00
Kausthub Kannan
08d394126c
Changed Mish Activation Function to use Softplus (#10111) 2023-10-08 11:48:22 -04:00
Om Alve
937ce83b15
Added fractionated_morse_cipher (#9442)
* Added fractionated_morse_cipher

* Added return type hint for main function

* Added doctest for main

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

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

* Replaced main function

* changed the references section

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

* removed repetitive datatype hint in the docstring

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

* changed dictionary comprehension variable names to something more compact

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

* Update fractionated_morse_cipher.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-08 13:05:01 +02: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
dhruvtrigotra
112daddc4d
charging_capacitor (#10016)
* charging_capacitor

* charging_capacitor

* Final edits

---------

Co-authored-by: Christian Clauss <cclauss@me.com>
2023-10-07 21:04:24 +02:00
Pronay Debnath
78af0c43c6
Create fractional_cover_problem.py (#9973)
* Create fractional_cover_problem.py

* Update fractional_cover_problem.py

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

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

* Update fractional_cover_problem.py

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

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

* Update fractional_cover_problem.py

* Update fractional_cover_problem.py

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

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

* Update fractional_cover_problem.py

* Update fractional_cover_problem.py

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

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

* Update fractional_cover_problem.py

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

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

* Lose __eq__()

* Update fractional_cover_problem.py

* Define Item property ratio

---------

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 17:51:30 +02:00
Saahil Mahato
678e0aa8cf
Mention square matrices in strassen docs and make it more clear (#9839)
* refactor: fix strassen matrix multiplication docs

* refactor: make docs more clear
2023-10-07 05:35:23 -04:00
Kamil
2122474e41
Segmented sieve - doctests (#9945)
* Replacing the generator with numpy vector operations from lu_decomposition.

* Revert "Replacing the generator with numpy vector operations from lu_decomposition."

This reverts commit ad217c6616.

* Added doctests.

* Update segmented_sieve.py

Removed unnecessary check.

* Update segmented_sieve.py

Added checks for 0 and negative numbers.

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

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

* Update segmented_sieve.py

* Update segmented_sieve.py

Added float number check.

* Update segmented_sieve.py

* Update segmented_sieve.py

simplified verification

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

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

* Update segmented_sieve.py

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

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

* Update segmented_sieve.py

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

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

* ValueError: Number 22.2 must instead be a positive integer

---------

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 05:09:39 -04:00
Kausthub Kannan
80a2087e0a
Added Softplus activation function (#9944) 2023-10-06 16:26:09 -04:00
Kausthub Kannan
c6ec99d571
Added Mish Activation Function (#9942)
* Added Mish Activation Function

* Apply suggestions from code review

---------

Co-authored-by: Tianyi Zheng <tianyizheng02@gmail.com>
2023-10-06 15:23:05 -04:00
fxdup
995c5533c6
Consolidate gamma (#9769)
* refactor(gamma): Append _iterative to func name

* refactor(gamma): Consolidate implementations

* refactor(gamma): Redundant test function removal

* Update maths/gamma.py

---------

Co-authored-by: Tianyi Zheng <tianyizheng02@gmail.com>
2023-10-06 14:46:58 -04:00
Sarvjeet Singh
795e97e87f
Added Majority Voting Algorithm (#9866)
* Create MajorityVoteAlgorithm.py

* Update and rename MajorityVoteAlgorithm.py to majorityvotealgorithm.py

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

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

* Update and rename majorityvotealgorithm.py to majority_vote_algorithm.py

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

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

* Update majority_vote_algorithm.py

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

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

* Update majority_vote_algorithm.py

* Update majority_vote_algorithm.py

* Update other/majority_vote_algorithm.py

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

* renaming variables majority_vote_algorithm.py

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

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

* Update majority_vote_algorithm.py

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

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

* Update majority_vote_algorithm.py

* Update majority_vote_algorithm.py

* Update majority_vote_algorithm.py

* Update majority_vote_algorithm.py

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

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

* Update other/majority_vote_algorithm.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/majority_vote_algorithm.py

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

* adding more testcases majority_vote_algorithm.py

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

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

* Update majority_vote_algorithm.py

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

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

* Update majority_vote_algorithm.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-06 15:49:34 +02:00
Christian Clauss
d0c54acd75
Use dataclasses in singly_linked_list.py (#9886) 2023-10-06 15:31:11 +13:00
JeevaRamanathan
17af644449
Symmetric tree (#9871)
* symmectric tree

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

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

* removed trailing spaces

* escape sequence fix

* added return type

* added class

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

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

* wordings fix

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

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

* added static method

* added type

* added static method

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

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

* wordings fix

* testcase added

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

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

* testcase added for mirror function

* testcase added for mirror function

* made the requested changes

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

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

* made the requested changes

* doc test added for symmetric, asymmetric

* Update symmetric_tree.py

---------

Co-authored-by: jeevaramanthan.m <jeevaramanathan.m@infosys.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>
2023-10-06 02:00:58 +02:00
ojas wani
19fc788197
added laplacian_filter file (#9783)
* added laplacian_filter file

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

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

* updated laplacian.py

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

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

* updated laplacian_py

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

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

* updated laplacian_filter.py

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

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

* updated laplacian_filter.py

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

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

* updated laplacian_filter.py

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

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

* required changes to laplacian file

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

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

* changed laplacian_filter.py

* changed laplacian_filter.py

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

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

* changed laplacian_filter.py

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

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

* changed laplacian_filter.py

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

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

* updated laplacian_filter.py

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

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

* update laplacian_filter.py

* update laplacian_filter.py

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

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

* update laplacian_filter.py

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

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

* changed laplacian_filter.py

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

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

* changed laplacian_filter.py

* changed laplacian_filter.py

* changed laplacian_filter.py

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

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

* Update laplacian_filter.py

* Add a test

---------

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-06 01:43:45 +02:00
Aroson
9200c64464
Added Wheatstone Bridge Algorithm (#9872)
* Add files via upload

* Update wheatstone_bridge.py

* Update wheatstone_bridge.py
2023-10-06 01:16:51 +02:00
Dean Bring
cd684fd947
Added algorithm to deeply clone a graph (#9765)
* Added algorithm to deeply clone a graph

* Fixed file name and removed a function call

* Removed nested function and fixed class parameter types

* Fixed doctests

* bug fix

* Added class decorator

* Updated doctests and fixed precommit errors

* Cleaned up code

* Simplified doctest

* Added doctests

* Code simplification
2023-10-06 00:45:40 +02:00
Abul Hasan
b316a96128
Match a pattern and String using backtracking (#9861)
* Fix: Issue 9588

* Fix: Issue 9588

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

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

* Fix: Issue 9588

* Fix: Issue #9588

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

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

* Fix: Issue #9588

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

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

* Fix: Issue #9588

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

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

* fix: issue #9793

* fix: issue #9793

* fix: issue #9588

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

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

* fix: issue #9844

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

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

* fix: issue #9844

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

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

* fix: issue #9844

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

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

* fix: issue #9844

* [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-06 11:45:10 +13:00
Akshay B Shetty
13317e4f7f
feat: calculating the resitance of resistor using color codes (#9874) 2023-10-06 11:27:13 +13:00
Marek Mazij
7f94a73eec
camelCase to snake_case conversion - Fixes #9726 (#9727)
* First commit

camel case to snake case conversion algorithm, including numbers

* code modified to not use regex
2023-10-06 11:05:23 +13:00
Christian Clauss
5869fda742
print reverse: A LinkedList with a tail pointer (#9875)
* print reverse: A LinkedList with a tail pointer

* updating DIRECTORY.md

---------

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2023-10-06 10:55:13 +13:00
Muhammad Umer Farooq
cffdf99c55
Updated prime_numbers.py testcases. (#9851)
* Updated prime_numbers.py testcases.

* revert __main__ code.
2023-10-05 20:44:55 +02:00
Pronay Debnath
b76115e8d1
Updated check_bipartite_graph_dfs.py (#9525)
* Create dijkstra_algorithm.py

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

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

* Update dijkstra_algorithm.py

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

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

* Update dijkstra_algorithm.py

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

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

* Update dijkstra_algorithm.py

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

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

* Delete greedy_methods/dijkstra_algorithm.py

* Update check_bipartite_graph_dfs.py

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

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

* Update check_bipartite_graph_dfs.py

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

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

* Update graphs/check_bipartite_graph_dfs.py

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

* Update graphs/check_bipartite_graph_dfs.py

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

* Update check_bipartite_graph_dfs.py

* Update check_bipartite_graph_dfs.py

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

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

* Update check_bipartite_graph_dfs.py

* Update check_bipartite_graph_dfs.py

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

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

* Update check_bipartite_graph_dfs.py

* Update check_bipartite_graph_dfs.py

* Update check_bipartite_graph_dfs.py

* Let's use self-documenting variable names

This is complex code so let's use self-documenting function and variable names to help readers to understand.

We should not shorten names to simplify the code formatting but use understandable name and leave to code formatting to psf/black.

I am not sure if `nbor` was supposed to be `neighbour`.  ;-)

* Update check_bipartite_graph_dfs.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-05 19:33:05 +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