Skip to content

Commit 99bd1f9

Browse files
committed
Merge branch 'master' into reduce-the-complexity-of-digital_image_processing/edge_detection/canny.py
2 parents 1193f67 + 9720e6a commit 99bd1f9

File tree

251 files changed

+3175
-1357
lines changed

Some content is hidden

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

251 files changed

+3175
-1357
lines changed

Diff for: .flake8

+4-2
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,7 @@ max-line-length = 88
44
max-complexity = 19
55
extend-ignore =
66
# Formatting style for `black`
7-
E203 # Whitespace before ':'
8-
W503 # Line break occurred before a binary operator
7+
# E203 is whitespace before ':'
8+
E203,
9+
# W503 is line break occurred before a binary operator
10+
W503

Diff for: .pre-commit-config.yaml

+26-9
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
repos:
22
- repo: https://github.com/pre-commit/pre-commit-hooks
3-
rev: v4.3.0
3+
rev: v4.4.0
44
hooks:
55
- id: check-executables-have-shebangs
66
- id: check-yaml
@@ -10,37 +10,54 @@ repos:
1010
- id: requirements-txt-fixer
1111

1212
- repo: https://github.com/MarcoGorelli/auto-walrus
13-
rev: v0.2.1
13+
rev: v0.2.2
1414
hooks:
1515
- id: auto-walrus
1616

1717
- repo: https://github.com/psf/black
18-
rev: 22.10.0
18+
rev: 23.1.0
1919
hooks:
2020
- id: black
2121

2222
- repo: https://github.com/PyCQA/isort
23-
rev: 5.10.1
23+
rev: 5.12.0
2424
hooks:
2525
- id: isort
2626
args:
2727
- --profile=black
2828

29+
- repo: https://github.com/tox-dev/pyproject-fmt
30+
rev: "0.9.2"
31+
hooks:
32+
- id: pyproject-fmt
33+
34+
- repo: https://github.com/abravalheri/validate-pyproject
35+
rev: v0.12.1
36+
hooks:
37+
- id: validate-pyproject
38+
2939
- repo: https://github.com/asottile/pyupgrade
30-
rev: v3.2.0
40+
rev: v3.3.1
3141
hooks:
3242
- id: pyupgrade
3343
args:
34-
- --py310-plus
44+
- --py311-plus
45+
46+
- repo: https://github.com/charliermarsh/ruff-pre-commit
47+
rev: v0.0.253
48+
hooks:
49+
- id: ruff
50+
args:
51+
- --ignore=E741
3552

3653
- repo: https://github.com/PyCQA/flake8
37-
rev: 5.0.4
54+
rev: 6.0.0
3855
hooks:
3956
- id: flake8 # See .flake8 for args
4057
additional_dependencies: &flake8-plugins
4158
- flake8-bugbear
4259
- flake8-builtins
43-
- flake8-broken-line
60+
# - flake8-broken-line
4461
- flake8-comprehensions
4562
- pep8-naming
4663

@@ -52,7 +69,7 @@ repos:
5269
*flake8-plugins
5370

5471
- repo: https://github.com/pre-commit/mirrors-mypy
55-
rev: v0.982
72+
rev: v1.0.1
5673
hooks:
5774
- id: mypy
5875
args:

Diff for: DIRECTORY.md

+24-8
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414

1515
## Audio Filters
1616
* [Butterworth Filter](audio_filters/butterworth_filter.py)
17-
* [Equal Loudness Filter](audio_filters/equal_loudness_filter.py)
1817
* [Iir Filter](audio_filters/iir_filter.py)
1918
* [Show Response](audio_filters/show_response.py)
2019

@@ -33,6 +32,7 @@
3332
* [Rat In Maze](backtracking/rat_in_maze.py)
3433
* [Sudoku](backtracking/sudoku.py)
3534
* [Sum Of Subsets](backtracking/sum_of_subsets.py)
35+
* [Word Search](backtracking/word_search.py)
3636

3737
## Bit Manipulation
3838
* [Binary And Operator](bit_manipulation/binary_and_operator.py)
@@ -49,6 +49,7 @@
4949
* [Index Of Rightmost Set Bit](bit_manipulation/index_of_rightmost_set_bit.py)
5050
* [Is Even](bit_manipulation/is_even.py)
5151
* [Is Power Of Two](bit_manipulation/is_power_of_two.py)
52+
* [Numbers Different Signs](bit_manipulation/numbers_different_signs.py)
5253
* [Reverse Bits](bit_manipulation/reverse_bits.py)
5354
* [Single Bit Manipulation Operations](bit_manipulation/single_bit_manipulation_operations.py)
5455

@@ -77,6 +78,7 @@
7778
* [A1Z26](ciphers/a1z26.py)
7879
* [Affine Cipher](ciphers/affine_cipher.py)
7980
* [Atbash](ciphers/atbash.py)
81+
* [Autokey](ciphers/autokey.py)
8082
* [Baconian Cipher](ciphers/baconian_cipher.py)
8183
* [Base16](ciphers/base16.py)
8284
* [Base32](ciphers/base32.py)
@@ -121,6 +123,7 @@
121123
* [Huffman](compression/huffman.py)
122124
* [Lempel Ziv](compression/lempel_ziv.py)
123125
* [Lempel Ziv Decompress](compression/lempel_ziv_decompress.py)
126+
* [Lz77](compression/lz77.py)
124127
* [Peak Signal To Noise Ratio](compression/peak_signal_to_noise_ratio.py)
125128
* [Run Length Encoding](compression/run_length_encoding.py)
126129

@@ -162,6 +165,7 @@
162165
## Data Structures
163166
* Arrays
164167
* [Permutations](data_structures/arrays/permutations.py)
168+
* [Prefix Sum](data_structures/arrays/prefix_sum.py)
165169
* Binary Tree
166170
* [Avl Tree](data_structures/binary_tree/avl_tree.py)
167171
* [Basic Binary Tree](data_structures/binary_tree/basic_binary_tree.py)
@@ -172,8 +176,10 @@
172176
* [Binary Tree Path Sum](data_structures/binary_tree/binary_tree_path_sum.py)
173177
* [Binary Tree Traversals](data_structures/binary_tree/binary_tree_traversals.py)
174178
* [Diff Views Of Binary Tree](data_structures/binary_tree/diff_views_of_binary_tree.py)
179+
* [Distribute Coins](data_structures/binary_tree/distribute_coins.py)
175180
* [Fenwick Tree](data_structures/binary_tree/fenwick_tree.py)
176181
* [Inorder Tree Traversal 2022](data_structures/binary_tree/inorder_tree_traversal_2022.py)
182+
* [Is Bst](data_structures/binary_tree/is_bst.py)
177183
* [Lazy Segment Tree](data_structures/binary_tree/lazy_segment_tree.py)
178184
* [Lowest Common Ancestor](data_structures/binary_tree/lowest_common_ancestor.py)
179185
* [Maximum Fenwick Tree](data_structures/binary_tree/maximum_fenwick_tree.py)
@@ -323,6 +329,7 @@
323329
* [Subset Generation](dynamic_programming/subset_generation.py)
324330
* [Sum Of Subset](dynamic_programming/sum_of_subset.py)
325331
* [Viterbi](dynamic_programming/viterbi.py)
332+
* [Word Break](dynamic_programming/word_break.py)
326333

327334
## Electronics
328335
* [Builtin Voltage](electronics/builtin_voltage.py)
@@ -372,6 +379,7 @@
372379
* [Articulation Points](graphs/articulation_points.py)
373380
* [Basic Graphs](graphs/basic_graphs.py)
374381
* [Bellman Ford](graphs/bellman_ford.py)
382+
* [Bi Directional Dijkstra](graphs/bi_directional_dijkstra.py)
375383
* [Bidirectional A Star](graphs/bidirectional_a_star.py)
376384
* [Bidirectional Breadth First Search](graphs/bidirectional_breadth_first_search.py)
377385
* [Boruvka](graphs/boruvka.py)
@@ -469,8 +477,6 @@
469477
* [Decision Tree](machine_learning/decision_tree.py)
470478
* Forecasting
471479
* [Run](machine_learning/forecasting/run.py)
472-
* [Gaussian Naive Bayes](machine_learning/gaussian_naive_bayes.py)
473-
* [Gradient Boosting Regressor](machine_learning/gradient_boosting_regressor.py)
474480
* [Gradient Descent](machine_learning/gradient_descent.py)
475481
* [K Means Clust](machine_learning/k_means_clust.py)
476482
* [K Nearest Neighbours](machine_learning/k_nearest_neighbours.py)
@@ -484,8 +490,6 @@
484490
* [Lstm Prediction](machine_learning/lstm/lstm_prediction.py)
485491
* [Multilayer Perceptron Classifier](machine_learning/multilayer_perceptron_classifier.py)
486492
* [Polymonial Regression](machine_learning/polymonial_regression.py)
487-
* [Random Forest Classifier](machine_learning/random_forest_classifier.py)
488-
* [Random Forest Regressor](machine_learning/random_forest_regressor.py)
489493
* [Scoring Functions](machine_learning/scoring_functions.py)
490494
* [Self Organizing Map](machine_learning/self_organizing_map.py)
491495
* [Sequential Minimum Optimization](machine_learning/sequential_minimum_optimization.py)
@@ -506,6 +510,7 @@
506510
* [Area](maths/area.py)
507511
* [Area Under Curve](maths/area_under_curve.py)
508512
* [Armstrong Numbers](maths/armstrong_numbers.py)
513+
* [Automorphic Number](maths/automorphic_number.py)
509514
* [Average Absolute Deviation](maths/average_absolute_deviation.py)
510515
* [Average Mean](maths/average_mean.py)
511516
* [Average Median](maths/average_median.py)
@@ -527,6 +532,7 @@
527532
* [Collatz Sequence](maths/collatz_sequence.py)
528533
* [Combinations](maths/combinations.py)
529534
* [Decimal Isolate](maths/decimal_isolate.py)
535+
* [Decimal To Fraction](maths/decimal_to_fraction.py)
530536
* [Dodecahedron](maths/dodecahedron.py)
531537
* [Double Factorial Iterative](maths/double_factorial_iterative.py)
532538
* [Double Factorial Recursive](maths/double_factorial_recursive.py)
@@ -537,8 +543,7 @@
537543
* [Euler Modified](maths/euler_modified.py)
538544
* [Eulers Totient](maths/eulers_totient.py)
539545
* [Extended Euclidean Algorithm](maths/extended_euclidean_algorithm.py)
540-
* [Factorial Iterative](maths/factorial_iterative.py)
541-
* [Factorial Recursive](maths/factorial_recursive.py)
546+
* [Factorial](maths/factorial.py)
542547
* [Factors](maths/factors.py)
543548
* [Fermat Little Theorem](maths/fermat_little_theorem.py)
544549
* [Fibonacci](maths/fibonacci.py)
@@ -551,14 +556,17 @@
551556
* [Gamma Recursive](maths/gamma_recursive.py)
552557
* [Gaussian](maths/gaussian.py)
553558
* [Gaussian Error Linear Unit](maths/gaussian_error_linear_unit.py)
559+
* [Gcd Of N Numbers](maths/gcd_of_n_numbers.py)
554560
* [Greatest Common Divisor](maths/greatest_common_divisor.py)
555561
* [Greedy Coin Change](maths/greedy_coin_change.py)
556562
* [Hamming Numbers](maths/hamming_numbers.py)
557563
* [Hardy Ramanujanalgo](maths/hardy_ramanujanalgo.py)
564+
* [Hexagonal Number](maths/hexagonal_number.py)
558565
* [Integration By Simpson Approx](maths/integration_by_simpson_approx.py)
559566
* [Is Ip V4 Address Valid](maths/is_ip_v4_address_valid.py)
560567
* [Is Square Free](maths/is_square_free.py)
561568
* [Jaccard Similarity](maths/jaccard_similarity.py)
569+
* [Juggler Sequence](maths/juggler_sequence.py)
562570
* [Kadanes](maths/kadanes.py)
563571
* [Karatsuba](maths/karatsuba.py)
564572
* [Krishnamurthy Number](maths/krishnamurthy_number.py)
@@ -567,6 +575,7 @@
567575
* [Largest Subarray Sum](maths/largest_subarray_sum.py)
568576
* [Least Common Multiple](maths/least_common_multiple.py)
569577
* [Line Length](maths/line_length.py)
578+
* [Liouville Lambda](maths/liouville_lambda.py)
570579
* [Lucas Lehmer Primality Test](maths/lucas_lehmer_primality_test.py)
571580
* [Lucas Series](maths/lucas_series.py)
572581
* [Maclaurin Series](maths/maclaurin_series.py)
@@ -600,6 +609,7 @@
600609
* [Prime Sieve Eratosthenes](maths/prime_sieve_eratosthenes.py)
601610
* [Primelib](maths/primelib.py)
602611
* [Print Multiplication Table](maths/print_multiplication_table.py)
612+
* [Pronic Number](maths/pronic_number.py)
603613
* [Proth Number](maths/proth_number.py)
604614
* [Pythagoras](maths/pythagoras.py)
605615
* [Qr Decomposition](maths/qr_decomposition.py)
@@ -635,6 +645,7 @@
635645
* [Test Prime Check](maths/test_prime_check.py)
636646
* [Trapezoidal Rule](maths/trapezoidal_rule.py)
637647
* [Triplet Sum](maths/triplet_sum.py)
648+
* [Twin Prime](maths/twin_prime.py)
638649
* [Two Pointer](maths/two_pointer.py)
639650
* [Two Sum](maths/two_sum.py)
640651
* [Ugly Numbers](maths/ugly_numbers.py)
@@ -907,6 +918,8 @@
907918
* [Sol1](project_euler/problem_080/sol1.py)
908919
* Problem 081
909920
* [Sol1](project_euler/problem_081/sol1.py)
921+
* Problem 082
922+
* [Sol1](project_euler/problem_082/sol1.py)
910923
* Problem 085
911924
* [Sol1](project_euler/problem_085/sol1.py)
912925
* Problem 086
@@ -943,6 +956,8 @@
943956
* [Sol1](project_euler/problem_115/sol1.py)
944957
* Problem 116
945958
* [Sol1](project_euler/problem_116/sol1.py)
959+
* Problem 117
960+
* [Sol1](project_euler/problem_117/sol1.py)
946961
* Problem 119
947962
* [Sol1](project_euler/problem_119/sol1.py)
948963
* Problem 120
@@ -993,6 +1008,7 @@
9931008
* [Sol1](project_euler/problem_686/sol1.py)
9941009

9951010
## Quantum
1011+
* [Bb84](quantum/bb84.py)
9961012
* [Deutsch Jozsa](quantum/deutsch_jozsa.py)
9971013
* [Half Adder](quantum/half_adder.py)
9981014
* [Not Gate](quantum/not_gate.py)
@@ -1151,7 +1167,7 @@
11511167
* [Get Amazon Product Data](web_programming/get_amazon_product_data.py)
11521168
* [Get Imdb Top 250 Movies Csv](web_programming/get_imdb_top_250_movies_csv.py)
11531169
* [Get Imdbtop](web_programming/get_imdbtop.py)
1154-
* [Get Top Billioners](web_programming/get_top_billioners.py)
1170+
* [Get Top Billionaires](web_programming/get_top_billionaires.py)
11551171
* [Get Top Hn Posts](web_programming/get_top_hn_posts.py)
11561172
* [Get User Tweets](web_programming/get_user_tweets.py)
11571173
* [Giphy](web_programming/giphy.py)

Diff for: README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
<!-- Second row: -->
2323
<br>
2424
<a href="https://github.com/TheAlgorithms/Python/actions">
25-
<img src="https://img.shields.io/github/workflow/status/TheAlgorithms/Python/build?label=CI&logo=github&style=flat-square" height="20" alt="GitHub Workflow Status">
25+
<img src="https://img.shields.io/github/actions/workflow/status/TheAlgorithms/Python/build.yml?branch=master&label=CI&logo=github&style=flat-square" height="20" alt="GitHub Workflow Status">
2626
</a>
2727
<a href="https://github.com/pre-commit/pre-commit">
2828
<img src="https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white&style=flat-square" height="20" alt="pre-commit">

Diff for: arithmetic_analysis/newton_raphson_new.py

-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ def newton_raphson(
5959

6060
# Let's Execute
6161
if __name__ == "__main__":
62-
6362
# Find root of trigonometric function
6463
# Find value of pi
6564
print(f"The root of sin(x) = 0 is {newton_raphson('sin(x)', 2)}")

Diff for: audio_filters/iir_filter.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def set_coefficients(self, a_coeffs: list[float], b_coeffs: list[float]) -> None
4747
>>> filt.set_coefficients(a_coeffs, b_coeffs)
4848
"""
4949
if len(a_coeffs) < self.order:
50-
a_coeffs = [1.0] + a_coeffs
50+
a_coeffs = [1.0, *a_coeffs]
5151

5252
if len(a_coeffs) != self.order + 1:
5353
raise ValueError(

Diff for: backtracking/n_queens_math.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,6 @@ def depth_first_search(
107107

108108
# We iterate each column in the row to find all possible results in each row
109109
for col in range(n):
110-
111110
# We apply that we learned previously. First we check that in the current board
112111
# (possible_board) there are not other same value because if there is it means
113112
# that there are a collision in vertical. Then we apply the two formulas we
@@ -130,9 +129,9 @@ def depth_first_search(
130129

131130
# If it is False we call dfs function again and we update the inputs
132131
depth_first_search(
133-
possible_board + [col],
134-
diagonal_right_collisions + [row - col],
135-
diagonal_left_collisions + [row + col],
132+
[*possible_board, col],
133+
[*diagonal_right_collisions, row - col],
134+
[*diagonal_left_collisions, row + col],
136135
boards,
137136
n,
138137
)

Diff for: backtracking/rat_in_maze.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,12 @@ def run_maze(maze: list[list[int]], i: int, j: int, solutions: list[list[int]])
8888
solutions[i][j] = 1
8989
return True
9090

91-
lower_flag = (not (i < 0)) and (not (j < 0)) # Check lower bounds
91+
lower_flag = (not i < 0) and (not j < 0) # Check lower bounds
9292
upper_flag = (i < size) and (j < size) # Check upper bounds
9393

9494
if lower_flag and upper_flag:
9595
# check for already visited and block points.
96-
block_flag = (not (solutions[i][j])) and (not (maze[i][j]))
96+
block_flag = (not solutions[i][j]) and (not maze[i][j])
9797
if block_flag:
9898
# check visited
9999
solutions[i][j] = 1

Diff for: backtracking/sum_of_subsets.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def create_state_space_tree(
4444
nums,
4545
max_sum,
4646
index + 1,
47-
path + [nums[index]],
47+
[*path, nums[index]],
4848
result,
4949
remaining_nums_sum - nums[index],
5050
)

0 commit comments

Comments
 (0)