Skip to content

Commit f2c91bf

Browse files
authored
Merge branch 'TheAlgorithms:master' into combinatorics
2 parents 0b3dcc0 + edee8e6 commit f2c91bf

File tree

468 files changed

+2079
-1418
lines changed

Some content is hidden

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

468 files changed

+2079
-1418
lines changed

.github/CODEOWNERS

+5-5
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@
2121

2222
# /cellular_automata/
2323

24-
# /ciphers/ @cclauss # TODO: Uncomment this line after Hacktoberfest
24+
# /ciphers/
2525

2626
# /compression/
2727

2828
# /computer_vision/
2929

30-
# /conversions/ @cclauss # TODO: Uncomment this line after Hacktoberfest
30+
# /conversions/
3131

32-
# /data_structures/ @cclauss # TODO: Uncomment this line after Hacktoberfest
32+
# /data_structures/
3333

3434
# /digital_image_processing/
3535

@@ -67,7 +67,7 @@
6767

6868
# /neural_network/
6969

70-
# /other/ @cclauss # TODO: Uncomment this line after Hacktoberfest
70+
# /other/
7171

7272
# /project_euler/
7373

@@ -81,7 +81,7 @@
8181

8282
# /sorts/
8383

84-
# /strings/ @cclauss # TODO: Uncomment this line after Hacktoberfest
84+
# /strings/
8585

8686
# /traversals/
8787

.github/dependabot.yml

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Keep GitHub Actions up to date with Dependabot...
2+
# https://docs.github.com/en/code-security/dependabot/working-with-dependabot/keeping-your-actions-up-to-date-with-dependabot
3+
version: 2
4+
updates:
5+
- package-ecosystem: "github-actions"
6+
directory: "/"
7+
schedule:
8+
interval: "daily"

.github/workflows/build.yml

+7-7
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ jobs:
1010
runs-on: ubuntu-latest
1111
steps:
1212
- uses: actions/checkout@v4
13-
- uses: actions/setup-python@v4
13+
- uses: actions/setup-python@v5
1414
with:
1515
python-version: 3.12
1616
allow-prereleases: true
17-
- uses: actions/cache@v3
17+
- uses: actions/cache@v4
1818
with:
1919
path: ~/.cache/pip
2020
key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }}
@@ -25,10 +25,10 @@ jobs:
2525
- name: Run tests
2626
# TODO: #8818 Re-enable quantum tests
2727
run: pytest
28-
--ignore=quantum/q_fourier_transform.py
29-
--ignore=project_euler/
30-
--ignore=scripts/validate_solutions.py
31-
--cov-report=term-missing:skip-covered
32-
--cov=. .
28+
--ignore=quantum/q_fourier_transform.py
29+
--ignore=project_euler/
30+
--ignore=scripts/validate_solutions.py
31+
--cov-report=term-missing:skip-covered
32+
--cov=. .
3333
- if: ${{ success() }}
3434
run: scripts/build_directory_md.py 2>&1 | tee DIRECTORY.md

.github/workflows/directory_writer.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ jobs:
99
- uses: actions/checkout@v4
1010
with:
1111
fetch-depth: 0
12-
- uses: actions/setup-python@v4
12+
- uses: actions/setup-python@v5
1313
with:
1414
python-version: 3.x
1515
- name: Write DIRECTORY.md
1616
run: |
1717
scripts/build_directory_md.py 2>&1 | tee DIRECTORY.md
18-
git config --global user.name github-actions
19-
git config --global user.email '${GITHUB_ACTOR}@users.noreply.github.com'
18+
git config --global user.name "$GITHUB_ACTOR"
19+
git config --global user.email "$[email protected]"
2020
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY
2121
- name: Update DIRECTORY.md
2222
run: |

.github/workflows/project_euler.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
runs-on: ubuntu-latest
1616
steps:
1717
- uses: actions/checkout@v4
18-
- uses: actions/setup-python@v4
18+
- uses: actions/setup-python@v5
1919
with:
2020
python-version: 3.x
2121
- name: Install pytest and pytest-cov
@@ -27,7 +27,7 @@ jobs:
2727
runs-on: ubuntu-latest
2828
steps:
2929
- uses: actions/checkout@v4
30-
- uses: actions/setup-python@v4
30+
- uses: actions/setup-python@v5
3131
with:
3232
python-version: 3.x
3333
- name: Install pytest and requests

.github/workflows/ruff.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ jobs:
1111
ruff:
1212
runs-on: ubuntu-latest
1313
steps:
14-
- uses: actions/checkout@v4
15-
- run: pip install --user ruff
16-
- run: ruff --output-format=github .
14+
- uses: actions/checkout@v4
15+
- run: pip install --user ruff
16+
- run: ruff check --output-format=github .

.pre-commit-config.yaml

+15-13
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.5.0
3+
rev: v4.6.0
44
hooks:
55
- id: check-executables-have-shebangs
66
- id: check-toml
@@ -11,29 +11,25 @@ repos:
1111
- id: requirements-txt-fixer
1212

1313
- repo: https://github.com/MarcoGorelli/auto-walrus
14-
rev: v0.2.2
14+
rev: 0.3.4
1515
hooks:
16-
- id: auto-walrus
16+
- id: auto-walrus
1717

1818
- repo: https://github.com/astral-sh/ruff-pre-commit
19-
rev: v0.1.9
19+
rev: v0.4.5
2020
hooks:
2121
- id: ruff
22-
23-
- repo: https://github.com/psf/black
24-
rev: 23.12.1
25-
hooks:
26-
- id: black
22+
- id: ruff-format
2723

2824
- repo: https://github.com/codespell-project/codespell
29-
rev: v2.2.6
25+
rev: v2.3.0
3026
hooks:
3127
- id: codespell
3228
additional_dependencies:
3329
- tomli
3430

3531
- repo: https://github.com/tox-dev/pyproject-fmt
36-
rev: "1.5.3"
32+
rev: "2.1.3"
3733
hooks:
3834
- id: pyproject-fmt
3935

@@ -46,16 +42,22 @@ repos:
4642
pass_filenames: false
4743

4844
- repo: https://github.com/abravalheri/validate-pyproject
49-
rev: v0.15
45+
rev: v0.18
5046
hooks:
5147
- id: validate-pyproject
5248

5349
- repo: https://github.com/pre-commit/mirrors-mypy
54-
rev: v1.8.0
50+
rev: v1.10.0
5551
hooks:
5652
- id: mypy
5753
args:
5854
- --ignore-missing-imports
5955
- --install-types # See mirrors-mypy README.md
6056
- --non-interactive
6157
additional_dependencies: [types-requests]
58+
59+
- repo: https://github.com/pre-commit/mirrors-prettier
60+
rev: "v4.0.0-alpha.8"
61+
hooks:
62+
- id: prettier
63+
types_or: [toml, yaml]

DIRECTORY.md

+12-5
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@
134134
* [Run Length Encoding](compression/run_length_encoding.py)
135135

136136
## Computer Vision
137+
* [Cnn Classification](computer_vision/cnn_classification.py)
137138
* [Flip Augmentation](computer_vision/flip_augmentation.py)
138139
* [Haralick Descriptors](computer_vision/haralick_descriptors.py)
139140
* [Harris Corner](computer_vision/harris_corner.py)
@@ -344,12 +345,13 @@
344345
* [Floyd Warshall](dynamic_programming/floyd_warshall.py)
345346
* [Integer Partition](dynamic_programming/integer_partition.py)
346347
* [Iterating Through Submasks](dynamic_programming/iterating_through_submasks.py)
348+
* [K Means Clustering Tensorflow](dynamic_programming/k_means_clustering_tensorflow.py)
347349
* [Knapsack](dynamic_programming/knapsack.py)
348350
* [Largest Divisible Subset](dynamic_programming/largest_divisible_subset.py)
349351
* [Longest Common Subsequence](dynamic_programming/longest_common_subsequence.py)
350352
* [Longest Common Substring](dynamic_programming/longest_common_substring.py)
351353
* [Longest Increasing Subsequence](dynamic_programming/longest_increasing_subsequence.py)
352-
* [Longest Increasing Subsequence O(Nlogn)](dynamic_programming/longest_increasing_subsequence_o(nlogn).py)
354+
* [Longest Increasing Subsequence O Nlogn](dynamic_programming/longest_increasing_subsequence_o_nlogn.py)
353355
* [Longest Palindromic Subsequence](dynamic_programming/longest_palindromic_subsequence.py)
354356
* [Matrix Chain Multiplication](dynamic_programming/matrix_chain_multiplication.py)
355357
* [Matrix Chain Order](dynamic_programming/matrix_chain_order.py)
@@ -417,6 +419,7 @@
417419
* [Koch Snowflake](fractals/koch_snowflake.py)
418420
* [Mandelbrot](fractals/mandelbrot.py)
419421
* [Sierpinski Triangle](fractals/sierpinski_triangle.py)
422+
* [Vicsek](fractals/vicsek.py)
420423

421424
## Fuzzy Logic
422425
* [Fuzzy Operations](fuzzy_logic/fuzzy_operations.py)
@@ -462,7 +465,7 @@
462465
* [Dijkstra Alternate](graphs/dijkstra_alternate.py)
463466
* [Dijkstra Binary Grid](graphs/dijkstra_binary_grid.py)
464467
* [Dinic](graphs/dinic.py)
465-
* [Directed And Undirected (Weighted) Graph](graphs/directed_and_undirected_(weighted)_graph.py)
468+
* [Directed And Undirected Weighted Graph](graphs/directed_and_undirected_weighted_graph.py)
466469
* [Edmonds Karp Multiple Source And Sink](graphs/edmonds_karp_multiple_source_and_sink.py)
467470
* [Eulerian Path And Circuit For Undirected Graph](graphs/eulerian_path_and_circuit_for_undirected_graph.py)
468471
* [Even Tree](graphs/even_tree.py)
@@ -571,6 +574,8 @@
571574
* [Local Weighted Learning](machine_learning/local_weighted_learning/local_weighted_learning.py)
572575
* [Logistic Regression](machine_learning/logistic_regression.py)
573576
* [Loss Functions](machine_learning/loss_functions.py)
577+
* Lstm
578+
* [Lstm Prediction](machine_learning/lstm/lstm_prediction.py)
574579
* [Mfcc](machine_learning/mfcc.py)
575580
* [Multilayer Perceptron Classifier](machine_learning/multilayer_perceptron_classifier.py)
576581
* [Polynomial Regression](machine_learning/polynomial_regression.py)
@@ -631,7 +636,6 @@
631636
* [Floor](maths/floor.py)
632637
* [Gamma](maths/gamma.py)
633638
* [Gaussian](maths/gaussian.py)
634-
* [Gaussian Error Linear Unit](maths/gaussian_error_linear_unit.py)
635639
* [Gcd Of N Numbers](maths/gcd_of_n_numbers.py)
636640
* [Germain Primes](maths/germain_primes.py)
637641
* [Greatest Common Divisor](maths/greatest_common_divisor.py)
@@ -657,7 +661,6 @@
657661
* [Manhattan Distance](maths/manhattan_distance.py)
658662
* [Matrix Exponentiation](maths/matrix_exponentiation.py)
659663
* [Max Sum Sliding Window](maths/max_sum_sliding_window.py)
660-
* [Median Of Two Arrays](maths/median_of_two_arrays.py)
661664
* [Minkowski Distance](maths/minkowski_distance.py)
662665
* [Mobius Function](maths/mobius_function.py)
663666
* [Modular Division](maths/modular_division.py)
@@ -675,6 +678,7 @@
675678
* [Newton Forward Interpolation](maths/numerical_analysis/newton_forward_interpolation.py)
676679
* [Newton Raphson](maths/numerical_analysis/newton_raphson.py)
677680
* [Numerical Integration](maths/numerical_analysis/numerical_integration.py)
681+
* [Proper Fractions](maths/numerical_analysis/proper_fractions.py)
678682
* [Runge Kutta](maths/numerical_analysis/runge_kutta.py)
679683
* [Runge Kutta Fehlberg 45](maths/numerical_analysis/runge_kutta_fehlberg_45.py)
680684
* [Runge Kutta Gills](maths/numerical_analysis/runge_kutta_gills.py)
@@ -768,6 +772,7 @@
768772
* [Inverse Of Matrix](matrix/inverse_of_matrix.py)
769773
* [Largest Square Area In Matrix](matrix/largest_square_area_in_matrix.py)
770774
* [Matrix Class](matrix/matrix_class.py)
775+
* [Matrix Equalization](matrix/matrix_equalization.py)
771776
* [Matrix Multiplication Recursion](matrix/matrix_multiplication_recursion.py)
772777
* [Matrix Operation](matrix/matrix_operation.py)
773778
* [Max Area Of Island](matrix/max_area_of_island.py)
@@ -787,10 +792,10 @@
787792
* [Minimum Cut](networking_flow/minimum_cut.py)
788793

789794
## Neural Network
790-
* [2 Hidden Layers Neural Network](neural_network/2_hidden_layers_neural_network.py)
791795
* Activation Functions
792796
* [Binary Step](neural_network/activation_functions/binary_step.py)
793797
* [Exponential Linear Unit](neural_network/activation_functions/exponential_linear_unit.py)
798+
* [Gaussian Error Linear Unit](neural_network/activation_functions/gaussian_error_linear_unit.py)
794799
* [Leaky Rectified Linear Unit](neural_network/activation_functions/leaky_rectified_linear_unit.py)
795800
* [Mish](neural_network/activation_functions/mish.py)
796801
* [Rectified Linear Unit](neural_network/activation_functions/rectified_linear_unit.py)
@@ -801,7 +806,9 @@
801806
* [Swish](neural_network/activation_functions/swish.py)
802807
* [Back Propagation Neural Network](neural_network/back_propagation_neural_network.py)
803808
* [Convolution Neural Network](neural_network/convolution_neural_network.py)
809+
* [Input Data](neural_network/input_data.py)
804810
* [Simple Neural Network](neural_network/simple_neural_network.py)
811+
* [Two Hidden Layers Neural Network](neural_network/two_hidden_layers_neural_network.py)
805812

806813
## Other
807814
* [Activity Selection](other/activity_selection.py)

audio_filters/butterworth_filter.py

+15-7
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111

1212

1313
def make_lowpass(
14-
frequency: int, samplerate: int, q_factor: float = 1 / sqrt(2) # noqa: B008
14+
frequency: int,
15+
samplerate: int,
16+
q_factor: float = 1 / sqrt(2),
1517
) -> IIRFilter:
1618
"""
1719
Creates a low-pass filter
@@ -39,7 +41,9 @@ def make_lowpass(
3941

4042

4143
def make_highpass(
42-
frequency: int, samplerate: int, q_factor: float = 1 / sqrt(2) # noqa: B008
44+
frequency: int,
45+
samplerate: int,
46+
q_factor: float = 1 / sqrt(2),
4347
) -> IIRFilter:
4448
"""
4549
Creates a high-pass filter
@@ -67,7 +71,9 @@ def make_highpass(
6771

6872

6973
def make_bandpass(
70-
frequency: int, samplerate: int, q_factor: float = 1 / sqrt(2) # noqa: B008
74+
frequency: int,
75+
samplerate: int,
76+
q_factor: float = 1 / sqrt(2),
7177
) -> IIRFilter:
7278
"""
7379
Creates a band-pass filter
@@ -96,7 +102,9 @@ def make_bandpass(
96102

97103

98104
def make_allpass(
99-
frequency: int, samplerate: int, q_factor: float = 1 / sqrt(2) # noqa: B008
105+
frequency: int,
106+
samplerate: int,
107+
q_factor: float = 1 / sqrt(2),
100108
) -> IIRFilter:
101109
"""
102110
Creates an all-pass filter
@@ -124,7 +132,7 @@ def make_peak(
124132
frequency: int,
125133
samplerate: int,
126134
gain_db: float,
127-
q_factor: float = 1 / sqrt(2), # noqa: B008
135+
q_factor: float = 1 / sqrt(2),
128136
) -> IIRFilter:
129137
"""
130138
Creates a peak filter
@@ -156,7 +164,7 @@ def make_lowshelf(
156164
frequency: int,
157165
samplerate: int,
158166
gain_db: float,
159-
q_factor: float = 1 / sqrt(2), # noqa: B008
167+
q_factor: float = 1 / sqrt(2),
160168
) -> IIRFilter:
161169
"""
162170
Creates a low-shelf filter
@@ -193,7 +201,7 @@ def make_highshelf(
193201
frequency: int,
194202
samplerate: int,
195203
gain_db: float,
196-
q_factor: float = 1 / sqrt(2), # noqa: B008
204+
q_factor: float = 1 / sqrt(2),
197205
) -> IIRFilter:
198206
"""
199207
Creates a high-shelf filter

audio_filters/show_response.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from __future__ import annotations
22

3+
from abc import abstractmethod
34
from math import pi
45
from typing import Protocol
56

@@ -8,14 +9,14 @@
89

910

1011
class FilterType(Protocol):
12+
@abstractmethod
1113
def process(self, sample: float) -> float:
1214
"""
1315
Calculate y[n]
1416
1517
>>> issubclass(FilterType, Protocol)
1618
True
1719
"""
18-
return 0.0
1920

2021

2122
def get_bounds(

0 commit comments

Comments
 (0)