Commit Graph

3158 Commits

Author SHA1 Message Date
Chris O
c2f14e8a78
Add note to feature_request.yml about not opening issues for new algorithms (#10142) 2023-10-16 01:44:06 +02:00
Tianyi Zheng
73ebf7bdb1
Move and rename maths/greedy_coin_change.py (#10418)
* updating DIRECTORY.md

* updating DIRECTORY.md

* updating DIRECTORY.md

* updating DIRECTORY.md

* Move greedy_coin_change.py to greedy_methods/ and rename file

---------

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2023-10-16 01:42:55 +02:00
Tianyi Zheng
b6b45eb1ce
Fix numpy deprecation warning in 2_hidden_layers_neural_network.py (#10424)
* updating DIRECTORY.md

* updating DIRECTORY.md

* updating DIRECTORY.md

* updating DIRECTORY.md

* Fix deprecation warning in 2_hidden_layers_neural_network.py

Fix numpy deprecation warning:
DeprecationWarning: Conversion of an array with ndim > 0 to a scalar is deprecated, and will error in future. Ensure you extract a single element from your array before performing this operation. (Deprecated NumPy 1.25.)

---------

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2023-10-16 01:41:45 +02: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
Jeel Gajera
d00888de76
feat: adding Apriori Algorithm (#10491)
* feat: adding Apriori Algorithm

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

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

* fix: doctest, typo

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

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

* fix: type error, code refactore

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

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

* fix: refactore code

* fix: doctest

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

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

* fix: E501, B007

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

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

* fix: err

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

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

* fix: arg typ err

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

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

* fix: typo

* fix: typo

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

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

* Replace generate_candidates() with itertools.combinations()

* mypy

* Update apriori_algorithm.py

---------

Co-authored-by: Jeel Gajera <jeelgajera00@gmail.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-15 23:49:53 +02:00
Abílio Azevedo
bcda3bf64e
test: adding more tests to a star algorithm (#10397)
* test: adding more tests to a star algorithm

* Apply suggestions from code review

* Update a_star.py

---------

Co-authored-by: Tianyi Zheng <tianyizheng02@gmail.com>
2023-10-15 17:31:11 -04:00
dhruvtrigotra
ec952927ba
charging_inductor (#10427)
* charging_capacitor

* charging_capacitor

* Final edits

* charging_inductor

---------

Co-authored-by: Christian Clauss <cclauss@me.com>
2023-10-15 22:41:39 +02:00
hollowcrust
3d6f3c4188
Added data_structures/arrays/sparse_table.py (#10437)
* Create sparse_table.py

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

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

* Descriptive names for variables

* Fix ruff check error

* Update sparse_table.py

* Add comments, change variable names

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

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

* Fix typo

* Update sparse_table.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 22:13:27 +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
Christian Clauss
4004b862d5
Revert "validate_solutions.py: os.getenv('GITHUB_TOKEN', '')" (#10552)
* Revert "validate_solutions.py: os.getenv('GITHUB_TOKEN', '') (#10546)"

This reverts commit 68e6d5ad7e.

* updating DIRECTORY.md

---------

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2023-10-15 15:40:13 -04: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
Barun Parua
7bdd1cd2be
updated physics/archimedes_principle.py (#10479)
* avg and mps speed formulae added

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

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

* avg and mps speed formulae added

* fixed_spacing

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

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

* spacing

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

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

* ws

* added amicable numbers

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

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

* added amicable numbers

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

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

* spacing

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

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

* removed

* changed name of file and added code improvements

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

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

* issues fixed due to pi

* requested changes added

* added some doctests for exception handling, imported g from scipy and allowed zero gravity

* removed_scipy_import

* Update and rename archimedes_principle.py to archimedes_principle_of_buoyant_force.py

* Update archimedes_principle_of_buoyant_force.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 19:13:40 +02:00
Christian Clauss
68e6d5ad7e
validate_solutions.py: os.getenv('GITHUB_TOKEN', '') (#10546)
* validate_solutions.py: os.getenv('GITHUB_TOKEN', '')

@tianyizheng02

* updating DIRECTORY.md

* f this

---------

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2023-10-15 13:11:05 -04:00
K Anamithra
b2636d90b3
added implementing stack using two queues (#10076)
* added implementing stack using two queues

* Update Stack using two queues

* Update stack_using_two_queues.py

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

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

* Update stack_using_two_queues.py

* Update stack_using_two_queues.py

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

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

* Update stack_using_two_queues.py

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

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

* Update stack_using_two_queues.py

* Update stack_using_two_queues.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 18:41:29 +02:00
Aroson
52040a7bf1
Added 555 timer duty cycle and freqency in astable mode. (#10456)
* Add files via upload

* Update wheatstone_bridge.py

* Update wheatstone_bridge.py

* Create IC_555_Timer.py

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

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

* Update IC_555_Timer.py

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

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

* Update IC_555_Timer.py

* Update and rename IC_555_Timer.py to ic_555_timer.py

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

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

* Update ic_555_timer.py

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

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

* Update ic_555_timer.py

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

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

* Update ic_555_timer.py

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

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

* Cleanup ic_555_timer.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 17:35:02 +02:00
Tianyi Zheng
755659a62f
Omit project_euler/ from coverage reports (#10469)
* Omit project_euler/ and scripts/ from coverage reports

* Add scripts/ back into coverage reports
2023-10-15 17:16:56 +02:00
Rahul Jangra
b5474ab68a
[ADD] : maths joint probabilty distribution (#10508)
* Create joint_probability_distribution.py

* Update joint_probability_distribution.py

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

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

* Update joint_probability_distribution.py

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

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

* Update joint_probability_distribution.py

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

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

* Update joint_probability_distribution.py

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

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

* Update joint_probability_distribution.py

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

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

* Update joint_probability_distribution.py

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

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

* Update joint_probability_distribution.py

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

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

* Update joint_probability_distribution.py

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

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

* Update joint_probability_distribution.py

* Update joint_probability_distribution.py

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

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

* Update joint_probability_distribution.py

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

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

* Update joint_probability_distribution.py

* Update joint_probability_distribution.py

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

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

* Update maclaurin_series.py

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

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

* Revert changes to maclaurin_series.py

* Revert changes to maclaurin_series.py

* Update joint_probability_distribution.py

* Update joint_probability_distribution.py

* Update joint_probability_distribution.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 17:03:03 +02:00
Christian Clauss
79a91cca95
Fix typo in filename: ciphers/trifid_cipher.py (#10516)
* Update and rename trafid_cipher.py to trifid_cipher.py

* updating DIRECTORY.md

---------

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2023-10-15 10:57:08 -04:00
Ravi Kumar
777eca813a
Corrected typo in function name and doctests. rkf45.py (#10518)
* Corrected typo in function name and doctests. rkf45.py

There was a mistake in name of function (runge_futta_fehlberg instead of runge_kutta_fehlberg) . I have corrected this in function name and  also doctest.

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

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

* Rename rkf45.py to runge_kutta_fehlberg_45.py

* Update runge_kutta_fehlberg_45.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 12:55:56 +02:00
Kosuri L Indu
85cdb93a0d
[Add] : Job Sequence program under GREEDY methods (#10482)
* to add job seq program

* to add job seq program

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

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

* to add definitions in parameters

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

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

* to add definitions in parameters

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

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

* to add definitions in parameters

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

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

* changes as recommended

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

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

* type hint error resolved

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

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

* removed lambda

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

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

* import stmts order

* Update and rename job_sequence.py to job_sequence_with_deadline.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 12:18:28 +02:00
Manpreet Singh
1ebae5d43e
Performance: 75% faster Project Euler 187 (#10503)
* Add comments and wikipedia link in calculate_prime_numbers

* Add improved calculate_prime_numbers

* Separate slow_solution and new_solution

* Use for loops in solution

* Separate while_solution and new solution

* Add performance benchmark

* Add doctest for calculate_prime_numbers

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

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

* Removed white space

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2023-10-15 11:17:22 +02:00
Ravi Kumar
7dbc301818
added rkf45 method (#10438)
* added rkf45 method

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

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

* Updated rkf45.py

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

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

* Updated rkf45.py

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

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

* Update rkf45.py

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

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

* Update rkf45.py with suggestions

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

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

* Improved Code Quality rkf45.py

* Added more test cases and exception rkf45.py

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

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

* Update rkf45.py

* corrected some spellings. rkf45.py

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

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

* Update rkf45.py

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

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

* Update rkf45.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 11:07:29 +02:00
Manpreet Singh
3ecad36f92
fix: incorrect range detection in find_missing_number (#10361)
* Fix incorrect range detection in find_missing_number

* Support consecutive decreasing numbers

Added support for consecutive decreasing numbers in the find_missing_number function.

* Support unordered numbers
2023-10-15 00:45:44 -04:00
Tianyi Zheng
c9ba5e1b6f
Disable unused dependencies (#10467)
Comment out dependencies in requirements.txt that are only used by currently-disabled files
2023-10-14 22:08:52 +02:00
Saurabh Mahapatra
f968dda5e9
Updated Comments on upper.py (#10442)
* Updated Comments on upper.py

* Update upper.py

* Update upper.py

---------

Co-authored-by: Christian Clauss <cclauss@me.com>
2023-10-14 15:02:37 -04:00
Manpreet Singh
1969259868
Performance: 80% faster Project Euler 145 (#10445)
* Performance: 80% faster Project Euler145

* Added timeit benchmark

* >>> slow_solution() doctest
2023-10-14 19:35:01 +02:00
Aakash Giri
3ba2338479
Add Title Case Conversion (#10439)
[pre-commit.ci] auto fixes from pre-commit.com hooks

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

added more test case and type hint

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

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

updated naming convention
2023-10-14 18:17:11 +02:00
Dean Bring
212cdfe36c
Added validate sudoku board function (#9881)
* 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

* Created function which validates sudoku boards

* Update matrix/validate_sudoku_board.py

* Fixed precommit errors

* Removed file accidentally included

* Improved readability and simplicity

* Add timeit benchmarks

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

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

* Update validate_sudoku_board.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-14 17:35:12 +02:00
Tianyi Zheng
71b372f5e2
Remove doctest in xgboost_regressor.py main function (#10422)
* updating DIRECTORY.md

* updating DIRECTORY.md

* updating DIRECTORY.md

* updating DIRECTORY.md

* Update xgboost_regressor.py

---------

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2023-10-14 15:34:05 +02:00
Muhammad Umer Farooq
37cae3f561
Updated test cases of power_sum.py (#9978)
* Updated test cases of power_sum.py

* updated

* updated.

* remove extra comment and used ** instead of pow

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

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

* Update backtracking/power_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: Tianyi Zheng <tianyizheng02@gmail.com>
2023-10-14 04:31:43 -04:00
Baron105
0b2c9fb6f1
Adding avg and mps speed formulae for ideal gases (#10229)
* avg and mps speed formulae added

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

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

* avg and mps speed formulae added

* fixed_spacing

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

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

* spacing

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

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

* ws

* added amicable numbers

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

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

* added amicable numbers

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

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

* spacing

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

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

* removed

* changed name of file and added code improvements

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

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

* issues fixed due to pi

* requested changes added

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2023-10-14 03:01:23 -04:00
Dale Dai
9fb0cd271e
Expand euler phi function doctest (#10401) 2023-10-14 02:47:08 -04: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
Saurabh Mahapatra
1117a50665
Modified comments on lower.py (#10369) 2023-10-13 11:55:32 -04:00
Saahil Mahato
c85506262d
Add Damerau-Levenshtein distance algorithm (#10159)
* Add Damerau-Levenshtein distance algorithm

* fix: precommit check

* fix: doc correction

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

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

* refactor: use variable for length and doc correction

* Update damerau_levenshtein_distance.py

* Update damerau_levenshtein_distance.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 15:18:52 +02:00
Saahil Mahato
ebe66935d2
Add Solovay-Strassen Primality test (#10335)
* Add Solovay-Strassen Primality test

* fix: resolve comments

* refactor: docs change
2023-10-13 08:04:48 +02:00
Daniela Large
24f6f8c137
Added nimply gate to boolean_algebra (#10344)
* Add files via upload

* Update imply_gate.py

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

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

* Update boolean_algebra/imply_gate.py

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

* Update imply_gate.py

Made changes requested

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

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

* Update imply_gate.py

* Added nimply gate

* [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-13 00:29:39 -04:00
Pranavkumar Mallela
b94cdbab1a
add find triplets with 0 sum (3sum) (#10040)
* add find triplets with 0 sum (3sum)

* Update find_triplets_with_0_sum.py

* Update find_triplets_with_0_sum.py

---------

Co-authored-by: Christian Clauss <cclauss@me.com>
2023-10-12 21:51:53 +02:00
Daniela Large
ecf21bfc87
Added imply gate to boolean algebra (#9849)
* Add files via upload

* Update imply_gate.py

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

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

* Update boolean_algebra/imply_gate.py

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

* Update imply_gate.py

Made changes requested

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

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

* Update imply_gate.py

---------

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-12 11:51:06 -04:00
Poojan Smart
7ea812996c
Adds exponential moving average algorithm (#10273)
* Adds exponential moving average algorithm

* code clean up

* spell correction

* Modifies I/O types of function

* Replaces generator function

* Resolved mypy type error

* readibility of code and documentation

* Update exponential_moving_average.py

---------

Co-authored-by: Christian Clauss <cclauss@me.com>
2023-10-12 15:54:07 +02:00
Siddharth Warrier
09ce6b23d7
Count pairs with given sum (#10282)
* added power_of_4

* deleted power_of_4

* added pairs_with_given_sum

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

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

* updated the comment

* updated return hint

* updated type hints

* updated the variable

* updated annotation

* updated code

* updated code

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

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

* added the problem link and used defaultdict

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

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

* corrected import formatting

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

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

* Update pairs_with_given_sum.py

* Update data_structures/arrays/pairs_with_given_sum.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-12 11:08:55 +02:00
Vipin Karthic
92fbe60082
Added doctests to carmichael_number.py (#10210)
Co-authored-by: Tianyi Zheng <tianyizheng02@gmail.com>
2023-10-11 15:05:24 -04:00
Christian Clauss
3f094fe49d
Ruff pandas vet (#10281)
* Python linting: Add ruff rules for Pandas-vet and Pytest-style

* updating DIRECTORY.md

---------

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2023-10-11 14:30:02 -04:00
Aasheesh
d5323dbaee
Adding doctests in simpson_rule.py (#10269)
* Adding doctests in simpson_rule.py

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

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

* Update maths/simpson_rule.py

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

* Update maths/simpson_rule.py

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

* Adding doctests in simpson_rule.py

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

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

* Adding doctests in simpson_rule.py

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

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

* Adding doctests in simpson_rule.py

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

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

* Adding doctests in simpson_rule.py

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

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

* Adding doctests in simpson_rule.py

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

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

* Update simpson_rule.py

* Adding doctests in simpson_rule.py

* Adding doctests in simpson_rule.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-11 20:20:18 +02:00
Ricardo Martinez Peinado
5fb6496d1b
Improve primelib.py test coverage #9943 (#10251)
* Update the doctest of primelib.py

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

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

* Correct errors for the doctest of primelib.py

* last error for the doctest of primelib.py

* last error for the doctest of primelib.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-10-11 12:11:05 +02:00
hollowcrust
672fda9130
Fix bug and edit doctests for infix_to_prefix_conversion (#10259)
* Fix bug and edit doctests

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

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

* Add type hints, raiseError and other minor adjustments

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

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

* Cleaning code

* [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-11 11:00:49 +02:00
cornbread-eater
c850227bee
Add doctests to primelib.py (#10242)
* Update primelib.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>
2023-10-10 23:07:07 +02:00
Kamil
0070739233
k_means_clust - change to remove warning (#10244)
* 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.

* the change removes the warning:
/home/runner/work/Python/Python/machine_learning/k_means_clust.py:236: FutureWarning: The provided callable <function sum at 0x7f20c02034c0> is currently using SeriesGroupBy.sum. In a future version of pandas, the provided callable will be used directly. To keep current behavior pass the string "sum" instead.
     .agg(

And

/home/runner/work/Python/Python/machine_learning/k_means_clust.py:236: FutureWarning: The provided callable <function mean at 0x7f3d7db1c5e0> is currently using SeriesGroupBy.mean. In a future version of pandas, the provided callable will be used directly. To keep current behavior pass the string "mean" instead.
     .agg(
2023-10-10 16:18:31 -04:00
Kamil
9a5a6c663c
carmichael_number - add doctests (#10038)
* 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 carmichael_number.py

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

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

* Update carmichael_number.py

I make an empty commit to reset:
tests are failing.

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

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

* Update carmichael_number.py

Made changes taking into account the addition: 
from maths.greatest_common_divisor import greatest_common_divisor.

Now instead of gcd it is used: greatest_common_divisor.

* Update carmichael_number.py

* Update carmichael_number.py

* Update carmichael_number.py

I added a check for 0 and negative numbers in the tests and the code itself. Simplified obtaining the final result.

* Update carmichael_number.py

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

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

* Update maths/carmichael_number.py

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

* Update carmichael_number.py

* Update carmichael_number.py

---------

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-10 16:14:13 -04:00
hollowcrust
5be5d21bed
Add tests for infix_2_postfix() in infix_to_prefix_conversion.py (#10095)
* Add doctests, exceptions, type hints and fix bug for infix_to_prefix_conversion.py

Add doctests
Add exceptions for expressions with invalid bracket positions
Add type hints for functions
Fix a bug on line 53 (57 in PR)

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

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

* Change type hints in infix_to_prefix_conversion.py

* Remove printing trailing whitespace in the output table

* Fix type hint errors

* Fix doctests

* Adjust table convention in output and doctests

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

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

* Add doctests for infix_2_postfix()

* Update print_width

* Update print_width

* Fix the doctests

---------

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-10 18:52:53 +02:00