Commit Graph

2984 Commits

Author SHA1 Message Date
Manan Rathi
50485f7c8e
Fix typos in Sorts and Bit_manipulation (#4949)
* Fix several typos

* Update bit_manipulation/README.md

Co-authored-by: John Law <johnlaw.po@gmail.com>

* Update double_sort.py

Co-authored-by: John Law <johnlaw.po@gmail.com>
2021-10-20 16:42:32 +08:00
P U N I T H
83cf5786cd
Add wildcard pattern matching using dynamic programming (#5334)
* Added regular expression implimentation using dp

* replaced input() with example values

* Apply suggestions from code review

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

* changed returning value to bool and added test cases

* added doctest

Co-authored-by: John Law <johnlaw.po@gmail.com>

* added test cases

* Apply suggestions from code review

Co-authored-by: John Law <johnlaw.po@gmail.com>

* shifted to strings

* Changed filename

* Update function name to match_pattern

Co-authored-by: John Law <johnlaw.po@gmail.com>

* Update function name to match_pattern

Co-authored-by: John Law <johnlaw.po@gmail.com>

Co-authored-by: Christian Clauss <cclauss@me.com>
Co-authored-by: John Law <johnlaw.po@gmail.com>
2021-10-20 16:30:58 +08:00
Immiel
2e2e1b656c
singly_linked_list: Added additional documentation, type hints and test cases (#4988)
This is a followup to https://github.com/TheAlgorithms/Python/pull/4973#issuecomment-933117382

As per given suggestion, I've added type hints to certain methods that don't have them.  I have also added documentation and example doctests as a usage example for (most of) those that don't have them.

I have also added another test case following the previous test case's format. I noticed that the existing test case from previous pull request might be redundant with the ones I've made, so I decided to create a specific situation where the linked list would have to keep different kinds of data types for each node, in `test_singly_linked_list_2` test function.

Some minor changes in strings has been done to keep things consistent with other parts of the document. If it is undesirable, please let me know.
2021-10-20 16:08:39 +08:00
Snimerjot Singh
c886a66d34
Added check_strong_password.py (#4950)
* Added check_strong_password.py

* Corrected Comment

* Updated

* Updated check_strong_password.py

* Ran Pre-Commit
2021-10-20 07:35:41 +02:00
Alvin Philips
d32d0158a3
Fixed typo (#5439)
Changed it's (it is) to its
2021-10-19 21:39:15 +02:00
Rohan R Bharadwaj
21cf3cc260
Typo (#5443) 2021-10-19 21:36:01 +02:00
Christian Clauss
f7804334f1
length_conversion.py: Deal with uppercase and abbreviations (#5433)
* length_conversion.py: Deal with uppercase and abbreviations

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2021-10-19 11:11:49 +02:00
Vinicius Cordeiro
4880931c24
Add Polybius cipher (#5409)
* Add polybius cipher

* Fix polybius.py build issues and add test
2021-10-19 08:37:51 +02:00
Christian Clauss
aa0ace4df7
Remove exception detail from doctest (#5430)
* Remove exception detail from doctest

These details are configuration dependant so should be removed according to https://docs.python.org/3/library/doctest.html

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2021-10-19 08:05:20 +02:00
Sabari Ganesh
66c96aa037
Added length unit conversions (#5373)
* Added length unit conversions

Conversion of length units were added with respective tests being implemented and passed.
Available Units:- Metre,Kilometre,Feet,Inch,Centimeter,Yard,Foot,Mile,Millimeter

* Formatted File

File was formatted to go as per repo rules

* Reformatted file

* Reformatted code once again

* Added more test 

Added test to evaluate whether the code handles wrong arguements passed

* Update length_conversions.py

* Update length_conversions.py

* Update length_conversions.py

* Update length_conversions.py

* Update length_conversions.py

* Update length_conversions.py

* Update length_conversions.py

* Fixed  Minor errors in test

One of the test was failing and it was fixed

Co-authored-by: Christian Clauss <cclauss@me.com>
2021-10-19 07:26:03 +02:00
Jainendra Mandavi
d28463c75d
Create count_1s_brian_kernighan_method (#5385)
Ref - http://graphics.stanford.edu/~seander/bithacks.html#CountBitsSetKernighan
2021-10-18 18:53:10 +02:00
iradonov
4af5215042
added Schur complement to linear algebra (#4793)
* added schur complement and tests to linear algebra

* updated according to checklist

* updated variable names and typing

* added two testcases for input validation

* fixed import order

Co-authored-by: Ivan Radonov <ivan.radonov@ad.mentormate.bg>
2021-10-18 18:46:47 +02:00
Rohan R Bharadwaj
fa88559cab
Create join.py (#5363)
* Create join.py

Because we have a split.py

* Update join.py

* Update join.py

* Update join.py

* Update join.py

* Update join.py

* Update strings/join.py

Co-authored-by: John Law <johnlaw.po@gmail.com>

* Update join.py

* Update join.py

* Update join.py

* Update join.py

Co-authored-by: John Law <johnlaw.po@gmail.com>
2021-10-18 21:35:35 +08:00
Jaydeep Das
0935ab0cb2
Added giphy.py to fetch gifs on a given topic (#5378)
* Added giphy.py to fetch gifs on a given topic

* Modified code
[*]Added doctest
[*]Formatted with black

* Minor change

* Minor refactoring to avoid name clash

* Made necessary changes as per review

* Update web_programming/giphy.py

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

* Apply suggestions from code review

* Final cleanup

* Placate psf/black

Co-authored-by: Christian Clauss <cclauss@me.com>
2021-10-18 09:16:42 +02:00
Atharva Deshpande
1e64bf4600
Re-organize math/series (#5044)
* added harmonic mean

* Update maths/series/harmonic_mean.py

Updated the write-up of reference given in the code.

Co-authored-by: John Law <johnlaw.po@gmail.com>

* changes in arithmetic and geometric mean code

* mean and series added in a single file

Co-authored-by: John Law <johnlaw.po@gmail.com>
2021-10-18 12:46:23 +08:00
Meysam
08d4d226d7
[mypy] Fix type annotations for graphs/boruvka (#4867)
* fix: type annotations for pypi 🏷️

Fixes #4052

* updating DIRECTORY.md

* apply suggestions from code review

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

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
2021-10-17 18:26:12 +02:00
John Law
4bf2eedd3c
[mypy] fix mypy error in Project Euler Problem 092 solution 1 (#5357)
* fix mypy error

* updating DIRECTORY.md

* simplify code

* run black

* fix doc consistency

* Fix doc

* fix doc

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2021-10-17 08:07:45 +02:00
Srishtik Bhandarkar
7ef2e4d1d0
Add Project Euler Problem 092 (#5091)
* adde solution to problem 092

* added solution to problem 092

* fixed the pre-comit shebang issue
2021-10-17 01:08:41 +08:00
Christian Clauss
8dc7cdbc57
Add tests to morse_code.py (#5337)
* Add tests to morse_code.py

@dhruvmanila @poyea Your reviews, please.

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2021-10-16 18:57:38 +02:00
Saurabh Suresh Powar
433b804f7d
Added morphological operations, fixes: #5197 (#5199)
* Added morphological operations, fixes: #5197

* Added dilation tests and type hints

* Added erosion tests and type hints

* fixes: TheAlgorithms#5197

* fixes: TheAlgorithms#5197

* Update erosion_operation.py

* made suggested changes in dilation

* made suggested changes in erosion

* made suggested changes in dilation

* removed extra spaces in the tests

* removed extra spaces in the tests
2021-10-16 16:32:40 +02:00
Appledora
37385883aa
Improved readability of web_programming/get_imdbtop.py and added documentations with doctests (#4855)
* improved readability of the existing method by reformatting, adding documentations with doctests.

* improved readability of the existing method by reformatting, adding documentations with doctests.

* fixed typo in test

* added doctest to parse dictionary method

* added doctest to parse dictionary method

* Changed return type, removed print() from method and implemented doctests as suggested

* Fixed doctest error, removed print() from method, created new script as suggested

* Update get_imdbtop.py

* Fix typo discovered by codespell

* return ()

Co-authored-by: Christian Clauss <cclauss@me.com>
2021-10-16 03:32:33 +02:00
Appledora
152261765a
Show images from google query (#4853)
* Added new script to open the google image tab with a search query.

* Added new script to open the google image tab with a search query.

* Added new script to open the google image tab with a search query with doctests.

* Fixed doctest error, removed print() from method, changed return type

* Update web_programming/show_image_tab_from_google_query.py

using iterators instead of lists

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

* Update web_programming/show_image_tab_from_google_query.py

Improve readability by removing one-time used variable

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

* Update web_programming/show_image_tab_from_google_query.py

Decreasing complication through standard practices.

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

* Update web_programming/show_image_tab_from_google_query.py

Exception Handling

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

* changed complete method to download images from google search query

* Update download_images_from_google_query.py

* Delete show_image_tab_from_google_query.py

Co-authored-by: Christian Clauss <cclauss@me.com>
2021-10-16 02:02:44 +02:00
Murilo Gonçalves
4cf1aaeb96
Updated mypy.ini, removed ok folders that were excluded (#5331) 2021-10-15 23:57:41 +02:00
Manuel Di Lullo
1d457be29d
Matching min vertex cover (#5326)
* matching algorithm for min vertex cover problem

* fixed hint on row 37

* changed variable names

* provided doctest for get_edges function

* Removed dict.keys() iteration

* Update matching_min_vertex_cover.py

Co-authored-by: Christian Clauss <cclauss@me.com>
2021-10-15 17:03:57 +02:00
Manuel Di Lullo
908cb4f1e7
Greedy min vertex cover hacktoberfest (#5241)
* added complete graph generator function

* added doctest, type hints, wikipedia explanation

* added return type hint for function complete_graph

* added descriptive name for the parameter: n

* random graph generator with doctest and type hints

* added Greedy min vertex algorithm

* pre-commit hook(s) made changes

* Delete complete_graph_generator.py

* Delete random_graph_generator.py

* fixed doctest

* updated commit following highligths

* fixed following pre-commit highlights

* modified variables names
2021-10-15 15:04:38 +02:00
Rohan R Bharadwaj
545fec7a14
Fix documentation (#5311) 2021-10-15 12:33:39 +02:00
Christian Clauss
ca842b4add
It is OK to test ./scripts (#5290)
* It is OK to test ./scripts

* updating DIRECTORY.md

* Update build.yml

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2021-10-14 18:19:47 +02:00
Jordan Rinder
618f9ca885
Add Proth number to maths (#5246)
* Add Proth number to maths

* Add test for 0 and more informative output

* Fixing test failure issue - unused variable

* Update proth_number.py

Co-authored-by: Christian Clauss <cclauss@me.com>
2021-10-14 16:30:52 +02:00
Rohan R Bharadwaj
bb37ebbe50
Create baconian_cipher.py (#5251)
* Create baconian_cipher.py

* Update baconian_cipher.py

* Update baconian_cipher.py

* Update baconian_cipher.py

* Update baconian_cipher.py

* Update baconian_cipher.py

* Update baconian_cipher.py

* Update baconian_cipher.py

* Update baconian_cipher.py

* Update baconian_cipher.py

* Update baconian_cipher.py

* Update baconian_cipher.py

* Update baconian_cipher.py

* Update baconian_cipher.py

* Update baconian_cipher.py

* Update baconian_cipher.py

* Update baconian_cipher.py

* Update baconian_cipher.py

* Update baconian_cipher.py

* Update baconian_cipher.py

* Update baconian_cipher.py

* Update baconian_cipher.py

* Update baconian_cipher.py

* Update baconian_cipher.py

* Update baconian_cipher.py

* Update baconian_cipher.py

* Update baconian_cipher.py

* Update baconian_cipher.py

* Update baconian_cipher.py

* Update baconian_cipher.py

* Update baconian_cipher.py

* Update baconian_cipher.py

* Update baconian_cipher.py

* Update baconian_cipher.py
2021-10-14 16:01:38 +02:00
Rohan R Bharadwaj
d561de0bd9
Add surface area of cone and cylinder and hemisphere (#5220)
* Update area.py

* Update area.py

* Update area.py

* Update area.py

* Update area.py

* Update area.py

* Update area.py

* Update area.py
2021-10-14 13:23:18 +02:00
Aman kanojiya
9b4cb05ee5
Modified Euler's Method (#5258)
* Magnitude and Angle 

Core function to find Magnitude and Angle of two Given Vector

* Magnitude and Angle with Doctest

added Doctest to the functions

* Update linear_algebra/src/lib.py

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

* Update linear_algebra/src/lib.py

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

* Changes done 

and Magnitude and Angle Issues

* black

* Modified Euler's Method

Adding Modified Euler's method, which was the further change to a Euler method and known for better accuracy to the given value

* Modified Euler's Method (changed the typing of function)

Modified function is used for better accuracy

* Link added

Added link to an explanation as per Contributions Guidelines

* Resolving Pre-Commit error

* Pre-Commit Error Resolved

* Pre-Commit Error import statement Change

* Removed Import Math

* import math built issue

* adding space pre-commit error

* statement sorter for doc

Co-authored-by: Christian Clauss <cclauss@me.com>
2021-10-14 12:53:03 +02:00
Raj-Pansuriya
943e03fc54
Added Optimal Merge Pattern Algorithm (#5274)
* Minor changes due to precommit

* Update optimal_merge_pattern.py

Co-authored-by: Christian Clauss <cclauss@me.com>
2021-10-14 12:51:13 +02:00
Aman kanojiya
1b0ac73da2
Magnitude and Angle of Vector (#5225)
* Magnitude and Angle 

Core function to find Magnitude and Angle of two Given Vector

* Magnitude and Angle with Doctest

added Doctest to the functions

* Update linear_algebra/src/lib.py

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

* Update linear_algebra/src/lib.py

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

* Changes done 

and Magnitude and Angle Issues

* black

Co-authored-by: Christian Clauss <cclauss@me.com>
2021-10-12 11:51:27 +02:00
poloso
9586a6a98e
Change comments for improved consistency (#5223)
* Change comments for improved consistency

https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md#L56
https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md#L80
https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md#L87

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2021-10-12 00:44:38 +08:00
scfenton6
abaa0d754b
Add type annotations (#4814) 2021-10-12 00:34:30 +08:00
Joyce
bcfca67faa
[mypy] fix type annotations for all Project Euler problems (#4747)
* [mypy] fix type annotations for problem003/sol1 and problem003/sol3

* [mypy] fix type annotations for project euler problem007/sol2

* [mypy] fix type annotations for project euler problem008/sol2

* [mypy] fix type annotations for project euler problem009/sol1

* [mypy] fix type annotations for project euler problem014/sol1

* [mypy] fix type annotations for project euler problem 025/sol2

* [mypy] fix type annotations for project euler problem026/sol1.py

* [mypy] fix type annotations for project euler problem037/sol1

* [mypy] fix type annotations for project euler problem044/sol1

* [mypy] fix type annotations for project euler problem046/sol1

* [mypy] fix type annotations for project euler problem051/sol1

* [mypy] fix type annotations for project euler problem074/sol2

* [mypy] fix type annotations for project euler problem080/sol1

* [mypy] fix type annotations for project euler problem099/sol1

* [mypy] fix type annotations for project euler problem101/sol1

* [mypy] fix type annotations for project euler problem188/sol1

* [mypy] fix type annotations for project euler problem191/sol1

* [mypy] fix type annotations for project euler problem207/sol1

* [mypy] fix type annotations for project euler problem551/sol1
2021-10-12 00:33:44 +08:00
Muhammad Hammad Sani
e311b02e70
Remove unnecessary branch (#4824)
* Algorithm Optimized

* Update divide_and_conquer/inversions.py

Co-authored-by: John Law <johnlaw.po@gmail.com>

* Update divide_and_conquer/inversions.py

Co-authored-by: John Law <johnlaw.po@gmail.com>

* Update divide_and_conquer/inversions.py

Co-authored-by: John Law <johnlaw.po@gmail.com>

Co-authored-by: John Law <johnlaw.po@gmail.com>
2021-10-12 00:33:06 +08:00
Sidhaant Thakker
fadb97609f
Add carrier concentrations calculation algorithm (#4791)
* added carrier concentrations algorithm

* Add more references

Added more references to the carrier concentrations file

* Update electronics/carrier_concentration.py

Co-authored-by: John Law <johnlaw.po@gmail.com>

* Update electronics/carrier_concentration.py

Co-authored-by: John Law <johnlaw.po@gmail.com>

Co-authored-by: John Law <johnlaw.po@gmail.com>
2021-10-12 00:29:52 +08:00
Jordan Rinder
729b4d875a
Add Sylvester's sequence to maths (#5171)
* Add Sylvester's sequence to maths

* Update sylvester_sequence.py

Co-authored-by: Christian Clauss <cclauss@me.com>
2021-10-10 20:02:44 +02:00
Rohanrbharadwaj
97562c19f8
Added doctest (#5182) 2021-10-10 20:00:04 +02:00
Rohanrbharadwaj
7578e0b920
Used in-built method (#5183)
* Used in-built method

* Delete swap_case.py

Co-authored-by: Christian Clauss <cclauss@me.com>
2021-10-10 19:52:38 +02:00
Lewis Tian
77b243e62b
bugfix: Add empty list detection for find_max/min (#4881)
* bugfix: Add empty list detection for find_max/min

* fix shebangs check
2021-10-07 23:20:32 +08:00
Parth Satodiya
d324f91fe7
Fix mypy errors for data_structures->linked_list directory files (#4927) 2021-10-07 23:18:23 +08:00
Maxim Smolskiy
d654806eae
Improve Project Euler problem 112 solution 1 (#4808) 2021-10-06 22:11:50 +08:00
Maxim Smolskiy
629369a34f
Improve Project Euler problem 203 solution 1 (#4807) 2021-10-06 22:11:15 +08:00
Lewis Tian
a4d68d69f1
bugfix: Add abs_max.py & abs_min.py empty list detection (#4844)
* bugfix: Add abs_max.py & abs_min.py empty list detection

* fix shebangs check
2021-10-06 22:06:49 +08:00
Sarvesh Kumar Dwivedi
90db98304e
Fix word typos in comments (#4928)
* fixed: spelling

nonegative -> non-negative

* fixed: spelling

transpostiion -> transposition

* fixed: spelling

topolical -> topological

* fixed: spelling

sufix -> suffix
2021-10-04 12:07:58 +08:00
Nolan Emirot
d530d2bcf4
fix: comment in patience sort (#4972) 2021-10-04 11:33:42 +08:00
DukicDev
c873fa0b1b
Correct grammar of comment in backtracking/hamiltonian_cycle.py (#4868) 2021-10-02 15:51:53 +02:00
DukicDev
31b34af9fa
Correct grammar in backtracking/n_queens_math.py (#4869) 2021-10-02 15:37:28 +02:00