Skip to content

Commit 004183c

Browse files
authored
Merge branch 'master' into Python-3.10-beta-1
2 parents 728f0ed + 5d5831b commit 004183c

File tree

88 files changed

+2822
-1222
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+2822
-1222
lines changed

CONTRIBUTING.md

+13-13
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## Before contributing
44

5-
Welcome to [TheAlgorithms/Python](https://github.com/TheAlgorithms/Python)! Before sending your pull requests, make sure that you **read the whole guidelines**. If you have any doubt on the contributing guide, please feel free to [state it clearly in an issue](https://github.com/TheAlgorithms/Python/issues/new) or ask the community in [Gitter](https://gitter.im/TheAlgorithms).
5+
Welcome to [TheAlgorithms/Python](https://github.com/TheAlgorithms/Python)! Before sending your pull requests, make sure that you __read the whole guidelines__. If you have any doubt on the contributing guide, please feel free to [state it clearly in an issue](https://github.com/TheAlgorithms/Python/issues/new) or ask the community in [Gitter](https://gitter.im/TheAlgorithms).
66

77
## Contributing
88

@@ -15,9 +15,9 @@ We are very happy that you consider implementing algorithms and data structure f
1515
- Your work will be distributed under [MIT License](LICENSE.md) once your pull request is merged
1616
- You submitted work fulfils or mostly fulfils our styles and standards
1717

18-
**New implementation** is welcome! For example, new solutions for a problem, different representations for a graph data structure or algorithm designs with different complexity but **identical implementation** of an existing implementation is not allowed. Please check whether the solution is already implemented or not before submitting your pull request.
18+
__New implementation__ is welcome! For example, new solutions for a problem, different representations for a graph data structure or algorithm designs with different complexity but __identical implementation__ of an existing implementation is not allowed. Please check whether the solution is already implemented or not before submitting your pull request.
1919

20-
**Improving comments** and **writing proper tests** are also highly welcome.
20+
__Improving comments__ and __writing proper tests__ are also highly welcome.
2121

2222
### Contribution
2323

@@ -33,7 +33,7 @@ An Algorithm is one or more functions (or classes) that:
3333
* take one or more inputs,
3434
* perform some internal calculations or data manipulations,
3535
* return one or more outputs,
36-
* have minimal side effects (Ex. print(), plot(), read(), write()).
36+
* have minimal side effects (Ex. `print()`, `plot()`, `read()`, `write()`).
3737

3838
Algorithms should be packaged in a way that would make it easy for readers to put them into larger programs.
3939

@@ -42,7 +42,7 @@ Algorithms should:
4242
* use Python naming conventions and intuitive variable names to ease comprehension
4343
* be flexible to take different input values
4444
* have Python type hints for their input parameters and return values
45-
* raise Python exceptions (ValueError, etc.) on erroneous input values
45+
* raise Python exceptions (`ValueError`, etc.) on erroneous input values
4646
* have docstrings with clear explanations and/or URLs to source materials
4747
* contain doctests that test both valid and erroneous input values
4848
* return all calculation results instead of printing or plotting them
@@ -66,10 +66,10 @@ pre-commit run --all-files --show-diff-on-failure
6666

6767
We want your work to be readable by others; therefore, we encourage you to note the following:
6868

69-
- Please write in Python 3.7+. For instance: __print()__ is a function in Python 3 so __print "Hello"__ will _not_ work but __print("Hello")__ will.
69+
- Please write in Python 3.9+. For instance: `print()` is a function in Python 3 so `print "Hello"` will *not* work but `print("Hello")` will.
7070
- Please focus hard on naming of functions, classes, and variables. Help your reader by using __descriptive names__ that can help you to remove redundant comments.
71-
- Single letter variable names are _old school_ so please avoid them unless their life only spans a few lines.
72-
- Expand acronyms because __gcd()__ is hard to understand but __greatest_common_divisor()__ is not.
71+
- Single letter variable names are *old school* so please avoid them unless their life only spans a few lines.
72+
- Expand acronyms because `gcd()` is hard to understand but `greatest_common_divisor()` is not.
7373
- Please follow the [Python Naming Conventions](https://pep8.org/#prescriptive-naming-conventions) so variable_names and function_names should be lower_case, CONSTANTS in UPPERCASE, ClassNames should be CamelCase, etc.
7474

7575
- We encourage the use of Python [f-strings](https://realpython.com/python-f-strings/#f-strings-a-new-and-improved-way-to-format-strings-in-python) where they make the code easier to read.
@@ -81,7 +81,7 @@ We want your work to be readable by others; therefore, we encourage you to note
8181
black .
8282
```
8383

84-
- All submissions will need to pass the test __flake8 . --ignore=E203,W503 --max-line-length=88__ before they will be accepted so if possible, try this test locally on your Python file(s) before submitting your pull request.
84+
- All submissions will need to pass the test `flake8 . --ignore=E203,W503 --max-line-length=88` before they will be accepted so if possible, try this test locally on your Python file(s) before submitting your pull request.
8585

8686
```bash
8787
python3 -m pip install flake8 # only required the first time
@@ -134,15 +134,15 @@ We want your work to be readable by others; therefore, we encourage you to note
134134
python3 -m doctest -v my_submission.py
135135
```
136136

137-
The use of the Python builtin __input()__ function is **not** encouraged:
137+
The use of the Python builtin `input()` function is __not__ encouraged:
138138

139139
```python
140140
input('Enter your input:')
141141
# Or even worse...
142142
input = eval(input("Enter your input: "))
143143
```
144144

145-
However, if your code uses __input()__ then we encourage you to gracefully deal with leading and trailing whitespace in user input by adding __.strip()__ as in:
145+
However, if your code uses `input()` then we encourage you to gracefully deal with leading and trailing whitespace in user input by adding `.strip()` as in:
146146

147147
```python
148148
starting_value = int(input("Please enter a starting value: ").strip())
@@ -175,8 +175,8 @@ We want your work to be readable by others; therefore, we encourage you to note
175175
- All submissions will be tested with [__mypy__](http://www.mypy-lang.org) so we encourage to add [__Python type hints__](https://docs.python.org/3/library/typing.html) where it makes sense to do so.
176176

177177
- Most importantly,
178-
- **Be consistent in the use of these guidelines when submitting.**
179-
- **Join** [Gitter](https://gitter.im/TheAlgorithms) **now!**
178+
- __Be consistent in the use of these guidelines when submitting.__
179+
- __Join__ [Gitter](https://gitter.im/TheAlgorithms) __now!__
180180
- Happy coding!
181181

182182
Writer [@poyea](https://github.com/poyea), Jun 2019.

DIRECTORY.md

+21-2
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,9 @@
9797
* [Peak Signal To Noise Ratio](https://github.com/TheAlgorithms/Python/blob/master/compression/peak_signal_to_noise_ratio.py)
9898

9999
## Computer Vision
100-
* [Harriscorner](https://github.com/TheAlgorithms/Python/blob/master/computer_vision/harriscorner.py)
101-
* [Meanthreshold](https://github.com/TheAlgorithms/Python/blob/master/computer_vision/meanthreshold.py)
100+
* [Cnn Classification](https://github.com/TheAlgorithms/Python/blob/master/computer_vision/cnn_classification.py)
101+
* [Harris Corner](https://github.com/TheAlgorithms/Python/blob/master/computer_vision/harris_corner.py)
102+
* [Mean Threshold](https://github.com/TheAlgorithms/Python/blob/master/computer_vision/mean_threshold.py)
102103

103104
## Conversions
104105
* [Binary To Decimal](https://github.com/TheAlgorithms/Python/blob/master/conversions/binary_to_decimal.py)
@@ -108,6 +109,7 @@
108109
* [Decimal To Binary Recursion](https://github.com/TheAlgorithms/Python/blob/master/conversions/decimal_to_binary_recursion.py)
109110
* [Decimal To Hexadecimal](https://github.com/TheAlgorithms/Python/blob/master/conversions/decimal_to_hexadecimal.py)
110111
* [Decimal To Octal](https://github.com/TheAlgorithms/Python/blob/master/conversions/decimal_to_octal.py)
112+
* [Hex To Bin](https://github.com/TheAlgorithms/Python/blob/master/conversions/hex_to_bin.py)
111113
* [Hexadecimal To Decimal](https://github.com/TheAlgorithms/Python/blob/master/conversions/hexadecimal_to_decimal.py)
112114
* [Molecular Chemistry](https://github.com/TheAlgorithms/Python/blob/master/conversions/molecular_chemistry.py)
113115
* [Octal To Decimal](https://github.com/TheAlgorithms/Python/blob/master/conversions/octal_to_decimal.py)
@@ -135,6 +137,7 @@
135137
* [Segment Tree](https://github.com/TheAlgorithms/Python/blob/master/data_structures/binary_tree/segment_tree.py)
136138
* [Segment Tree Other](https://github.com/TheAlgorithms/Python/blob/master/data_structures/binary_tree/segment_tree_other.py)
137139
* [Treap](https://github.com/TheAlgorithms/Python/blob/master/data_structures/binary_tree/treap.py)
140+
* [Wavelet Tree](https://github.com/TheAlgorithms/Python/blob/master/data_structures/binary_tree/wavelet_tree.py)
138141
* Disjoint Set
139142
* [Alternate Disjoint Set](https://github.com/TheAlgorithms/Python/blob/master/data_structures/disjoint_set/alternate_disjoint_set.py)
140143
* [Disjoint Set](https://github.com/TheAlgorithms/Python/blob/master/data_structures/disjoint_set/disjoint_set.py)
@@ -231,6 +234,7 @@
231234
## Dynamic Programming
232235
* [Abbreviation](https://github.com/TheAlgorithms/Python/blob/master/dynamic_programming/abbreviation.py)
233236
* [Bitmask](https://github.com/TheAlgorithms/Python/blob/master/dynamic_programming/bitmask.py)
237+
* [Catalan Numbers](https://github.com/TheAlgorithms/Python/blob/master/dynamic_programming/catalan_numbers.py)
234238
* [Climbing Stairs](https://github.com/TheAlgorithms/Python/blob/master/dynamic_programming/climbing_stairs.py)
235239
* [Edit Distance](https://github.com/TheAlgorithms/Python/blob/master/dynamic_programming/edit_distance.py)
236240
* [Factorial](https://github.com/TheAlgorithms/Python/blob/master/dynamic_programming/factorial.py)
@@ -297,6 +301,7 @@
297301
* [Bfs Zero One Shortest Path](https://github.com/TheAlgorithms/Python/blob/master/graphs/bfs_zero_one_shortest_path.py)
298302
* [Bidirectional A Star](https://github.com/TheAlgorithms/Python/blob/master/graphs/bidirectional_a_star.py)
299303
* [Bidirectional Breadth First Search](https://github.com/TheAlgorithms/Python/blob/master/graphs/bidirectional_breadth_first_search.py)
304+
* [Boruvka](https://github.com/TheAlgorithms/Python/blob/master/graphs/boruvka.py)
300305
* [Breadth First Search](https://github.com/TheAlgorithms/Python/blob/master/graphs/breadth_first_search.py)
301306
* [Breadth First Search 2](https://github.com/TheAlgorithms/Python/blob/master/graphs/breadth_first_search_2.py)
302307
* [Breadth First Search Shortest Path](https://github.com/TheAlgorithms/Python/blob/master/graphs/breadth_first_search_shortest_path.py)
@@ -346,6 +351,7 @@
346351
* [Djb2](https://github.com/TheAlgorithms/Python/blob/master/hashes/djb2.py)
347352
* [Enigma Machine](https://github.com/TheAlgorithms/Python/blob/master/hashes/enigma_machine.py)
348353
* [Hamming Code](https://github.com/TheAlgorithms/Python/blob/master/hashes/hamming_code.py)
354+
* [Luhn](https://github.com/TheAlgorithms/Python/blob/master/hashes/luhn.py)
349355
* [Md5](https://github.com/TheAlgorithms/Python/blob/master/hashes/md5.py)
350356
* [Sdbm](https://github.com/TheAlgorithms/Python/blob/master/hashes/sdbm.py)
351357
* [Sha1](https://github.com/TheAlgorithms/Python/blob/master/hashes/sha1.py)
@@ -382,6 +388,8 @@
382388
* [Linear Discriminant Analysis](https://github.com/TheAlgorithms/Python/blob/master/machine_learning/linear_discriminant_analysis.py)
383389
* [Linear Regression](https://github.com/TheAlgorithms/Python/blob/master/machine_learning/linear_regression.py)
384390
* [Logistic Regression](https://github.com/TheAlgorithms/Python/blob/master/machine_learning/logistic_regression.py)
391+
* Lstm
392+
* [Lstm Prediction](https://github.com/TheAlgorithms/Python/blob/master/machine_learning/lstm/lstm_prediction.py)
385393
* [Multilayer Perceptron Classifier](https://github.com/TheAlgorithms/Python/blob/master/machine_learning/multilayer_perceptron_classifier.py)
386394
* [Polymonial Regression](https://github.com/TheAlgorithms/Python/blob/master/machine_learning/polymonial_regression.py)
387395
* [Random Forest Classifier](https://github.com/TheAlgorithms/Python/blob/master/machine_learning/random_forest_classifier.py)
@@ -416,10 +424,12 @@
416424
* [Binomial Distribution](https://github.com/TheAlgorithms/Python/blob/master/maths/binomial_distribution.py)
417425
* [Bisection](https://github.com/TheAlgorithms/Python/blob/master/maths/bisection.py)
418426
* [Ceil](https://github.com/TheAlgorithms/Python/blob/master/maths/ceil.py)
427+
* [Check Valid Ip Address](https://github.com/TheAlgorithms/Python/blob/master/maths/check_valid_ip_address.py)
419428
* [Chudnovsky Algorithm](https://github.com/TheAlgorithms/Python/blob/master/maths/chudnovsky_algorithm.py)
420429
* [Collatz Sequence](https://github.com/TheAlgorithms/Python/blob/master/maths/collatz_sequence.py)
421430
* [Combinations](https://github.com/TheAlgorithms/Python/blob/master/maths/combinations.py)
422431
* [Decimal Isolate](https://github.com/TheAlgorithms/Python/blob/master/maths/decimal_isolate.py)
432+
* [Double Factorial Recursive](https://github.com/TheAlgorithms/Python/blob/master/maths/double_factorial_recursive.py)
423433
* [Entropy](https://github.com/TheAlgorithms/Python/blob/master/maths/entropy.py)
424434
* [Euclidean Distance](https://github.com/TheAlgorithms/Python/blob/master/maths/euclidean_distance.py)
425435
* [Euclidean Gcd](https://github.com/TheAlgorithms/Python/blob/master/maths/euclidean_gcd.py)
@@ -534,6 +544,7 @@
534544

535545
## Other
536546
* [Activity Selection](https://github.com/TheAlgorithms/Python/blob/master/other/activity_selection.py)
547+
* [Date To Weekday](https://github.com/TheAlgorithms/Python/blob/master/other/date_to_weekday.py)
537548
* [Davis–Putnam–Logemann–Loveland](https://github.com/TheAlgorithms/Python/blob/master/other/davis–putnam–logemann–loveland.py)
538549
* [Dijkstra Bankers Algorithm](https://github.com/TheAlgorithms/Python/blob/master/other/dijkstra_bankers_algorithm.py)
539550
* [Doomsday](https://github.com/TheAlgorithms/Python/blob/master/other/doomsday.py)
@@ -783,6 +794,8 @@
783794
* [Sol1](https://github.com/TheAlgorithms/Python/blob/master/project_euler/problem_129/sol1.py)
784795
* Problem 135
785796
* [Sol1](https://github.com/TheAlgorithms/Python/blob/master/project_euler/problem_135/sol1.py)
797+
* Problem 144
798+
* [Sol1](https://github.com/TheAlgorithms/Python/blob/master/project_euler/problem_144/sol1.py)
786799
* Problem 173
787800
* [Sol1](https://github.com/TheAlgorithms/Python/blob/master/project_euler/problem_173/sol1.py)
788801
* Problem 174
@@ -847,6 +860,7 @@
847860
* [Counting Sort](https://github.com/TheAlgorithms/Python/blob/master/sorts/counting_sort.py)
848861
* [Cycle Sort](https://github.com/TheAlgorithms/Python/blob/master/sorts/cycle_sort.py)
849862
* [Double Sort](https://github.com/TheAlgorithms/Python/blob/master/sorts/double_sort.py)
863+
* [Exchange Sort](https://github.com/TheAlgorithms/Python/blob/master/sorts/exchange_sort.py)
850864
* [External Sort](https://github.com/TheAlgorithms/Python/blob/master/sorts/external_sort.py)
851865
* [Gnome Sort](https://github.com/TheAlgorithms/Python/blob/master/sorts/gnome_sort.py)
852866
* [Heap Sort](https://github.com/TheAlgorithms/Python/blob/master/sorts/heap_sort.py)
@@ -855,6 +869,7 @@
855869
* [Iterative Merge Sort](https://github.com/TheAlgorithms/Python/blob/master/sorts/iterative_merge_sort.py)
856870
* [Merge Insertion Sort](https://github.com/TheAlgorithms/Python/blob/master/sorts/merge_insertion_sort.py)
857871
* [Merge Sort](https://github.com/TheAlgorithms/Python/blob/master/sorts/merge_sort.py)
872+
* [Msd Radix Sort](https://github.com/TheAlgorithms/Python/blob/master/sorts/msd_radix_sort.py)
858873
* [Natural Sort](https://github.com/TheAlgorithms/Python/blob/master/sorts/natural_sort.py)
859874
* [Odd Even Sort](https://github.com/TheAlgorithms/Python/blob/master/sorts/odd_even_sort.py)
860875
* [Odd Even Transposition Parallel](https://github.com/TheAlgorithms/Python/blob/master/sorts/odd_even_transposition_parallel.py)
@@ -870,6 +885,7 @@
870885
* [Random Pivot Quick Sort](https://github.com/TheAlgorithms/Python/blob/master/sorts/random_pivot_quick_sort.py)
871886
* [Recursive Bubble Sort](https://github.com/TheAlgorithms/Python/blob/master/sorts/recursive_bubble_sort.py)
872887
* [Recursive Insertion Sort](https://github.com/TheAlgorithms/Python/blob/master/sorts/recursive_insertion_sort.py)
888+
* [Recursive Mergesort Array](https://github.com/TheAlgorithms/Python/blob/master/sorts/recursive_mergesort_array.py)
873889
* [Recursive Quick Sort](https://github.com/TheAlgorithms/Python/blob/master/sorts/recursive_quick_sort.py)
874890
* [Selection Sort](https://github.com/TheAlgorithms/Python/blob/master/sorts/selection_sort.py)
875891
* [Shell Sort](https://github.com/TheAlgorithms/Python/blob/master/sorts/shell_sort.py)
@@ -884,6 +900,7 @@
884900

885901
## Strings
886902
* [Aho Corasick](https://github.com/TheAlgorithms/Python/blob/master/strings/aho_corasick.py)
903+
* [Alternative String Arrange](https://github.com/TheAlgorithms/Python/blob/master/strings/alternative_string_arrange.py)
887904
* [Anagrams](https://github.com/TheAlgorithms/Python/blob/master/strings/anagrams.py)
888905
* [Autocomplete Using Trie](https://github.com/TheAlgorithms/Python/blob/master/strings/autocomplete_using_trie.py)
889906
* [Boyer Moore Search](https://github.com/TheAlgorithms/Python/blob/master/strings/boyer_moore_search.py)
@@ -893,6 +910,7 @@
893910
* [Check Pangram](https://github.com/TheAlgorithms/Python/blob/master/strings/check_pangram.py)
894911
* [Detecting English Programmatically](https://github.com/TheAlgorithms/Python/blob/master/strings/detecting_english_programmatically.py)
895912
* [Frequency Finder](https://github.com/TheAlgorithms/Python/blob/master/strings/frequency_finder.py)
913+
* [Indian Phone Validator](https://github.com/TheAlgorithms/Python/blob/master/strings/indian_phone_validator.py)
896914
* [Is Palindrome](https://github.com/TheAlgorithms/Python/blob/master/strings/is_palindrome.py)
897915
* [Jaro Winkler](https://github.com/TheAlgorithms/Python/blob/master/strings/jaro_winkler.py)
898916
* [Knuth Morris Pratt](https://github.com/TheAlgorithms/Python/blob/master/strings/knuth_morris_pratt.py)
@@ -932,6 +950,7 @@
932950
* [Instagram Crawler](https://github.com/TheAlgorithms/Python/blob/master/web_programming/instagram_crawler.py)
933951
* [Instagram Pic](https://github.com/TheAlgorithms/Python/blob/master/web_programming/instagram_pic.py)
934952
* [Instagram Video](https://github.com/TheAlgorithms/Python/blob/master/web_programming/instagram_video.py)
953+
* [Random Anime Character](https://github.com/TheAlgorithms/Python/blob/master/web_programming/random_anime_character.py)
935954
* [Recaptcha Verification](https://github.com/TheAlgorithms/Python/blob/master/web_programming/recaptcha_verification.py)
936955
* [Slack Message](https://github.com/TheAlgorithms/Python/blob/master/web_programming/slack_message.py)
937956
* [Test Fetch Github Info](https://github.com/TheAlgorithms/Python/blob/master/web_programming/test_fetch_github_info.py)

arithmetic_analysis/lu_decomposition.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,9 @@
66
from typing import Tuple
77

88
import numpy as np
9-
from numpy import ndarray
109

1110

12-
def lower_upper_decomposition(table: ndarray) -> Tuple[ndarray, ndarray]:
11+
def lower_upper_decomposition(table: np.ndarray) -> Tuple[np.ndarray, np.ndarray]:
1312
"""Lower-Upper (LU) Decomposition
1413
1514
Example:

arithmetic_analysis/secant_method.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,4 @@ def secant_method(lower_bound: float, upper_bound: float, repeats: int) -> float
2626

2727

2828
if __name__ == "__main__":
29-
print(f"Example: {secant_method(1, 3, 2) = }")
29+
print(f"Example: {secant_method(1, 3, 2)}")

0 commit comments

Comments
 (0)