Skip to content

Commit c3e3e4c

Browse files
Merge branch 'TheAlgorithms:master' into master
2 parents 7ce741d + ce43a8a commit c3e3e4c

25 files changed

+843
-147
lines changed

.pre-commit-config.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ repos:
1616
- id: auto-walrus
1717

1818
- repo: https://github.com/charliermarsh/ruff-pre-commit
19-
rev: v0.0.262
19+
rev: v0.0.269
2020
hooks:
2121
- id: ruff
2222

@@ -33,7 +33,7 @@ repos:
3333
- tomli
3434

3535
- repo: https://github.com/tox-dev/pyproject-fmt
36-
rev: "0.10.0"
36+
rev: "0.11.2"
3737
hooks:
3838
- id: pyproject-fmt
3939

@@ -46,12 +46,12 @@ repos:
4646
pass_filenames: false
4747

4848
- repo: https://github.com/abravalheri/validate-pyproject
49-
rev: v0.12.2
49+
rev: v0.13
5050
hooks:
5151
- id: validate-pyproject
5252

5353
- repo: https://github.com/pre-commit/mirrors-mypy
54-
rev: v1.2.0
54+
rev: v1.3.0
5555
hooks:
5656
- id: mypy
5757
args:

DIRECTORY.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,6 @@
294294
* [Mergesort](divide_and_conquer/mergesort.py)
295295
* [Peak](divide_and_conquer/peak.py)
296296
* [Power](divide_and_conquer/power.py)
297-
* [Strassen Matrix Multiplication](divide_and_conquer/strassen_matrix_multiplication.py)
298297

299298
## Dynamic Programming
300299
* [Abbreviation](dynamic_programming/abbreviation.py)
@@ -363,6 +362,7 @@
363362
## Financial
364363
* [Equated Monthly Installments](financial/equated_monthly_installments.py)
365364
* [Interest](financial/interest.py)
365+
* [Present Value](financial/present_value.py)
366366
* [Price Plus Tax](financial/price_plus_tax.py)
367367

368368
## Fractals
@@ -448,6 +448,7 @@
448448
## Greedy Methods
449449
* [Fractional Knapsack](greedy_methods/fractional_knapsack.py)
450450
* [Fractional Knapsack 2](greedy_methods/fractional_knapsack_2.py)
451+
* [Minimum Waiting Time](greedy_methods/minimum_waiting_time.py)
451452
* [Optimal Merge Pattern](greedy_methods/optimal_merge_pattern.py)
452453
* [Minimum Waiting Time ](greedy_methods/minimum_waiting_time.py)
453454

@@ -577,6 +578,7 @@
577578
* [Hexagonal Number](maths/hexagonal_number.py)
578579
* [Integration By Simpson Approx](maths/integration_by_simpson_approx.py)
579580
* [Is Ip V4 Address Valid](maths/is_ip_v4_address_valid.py)
581+
* [Is Palindrome](maths/is_palindrome.py)
580582
* [Is Square Free](maths/is_square_free.py)
581583
* [Jaccard Similarity](maths/jaccard_similarity.py)
582584
* [Juggler Sequence](maths/juggler_sequence.py)
@@ -605,6 +607,7 @@
605607
* [Newton Raphson](maths/newton_raphson.py)
606608
* [Number Of Digits](maths/number_of_digits.py)
607609
* [Numerical Integration](maths/numerical_integration.py)
610+
* [Odd Sieve](maths/odd_sieve.py)
608611
* [Perfect Cube](maths/perfect_cube.py)
609612
* [Perfect Number](maths/perfect_number.py)
610613
* [Perfect Square](maths/perfect_square.py)
@@ -631,6 +634,7 @@
631634
* [Radians](maths/radians.py)
632635
* [Radix2 Fft](maths/radix2_fft.py)
633636
* [Relu](maths/relu.py)
637+
* [Remove Digit](maths/remove_digit.py)
634638
* [Runge Kutta](maths/runge_kutta.py)
635639
* [Segmented Sieve](maths/segmented_sieve.py)
636640
* Series
@@ -656,6 +660,7 @@
656660
* [Sum Of Harmonic Series](maths/sum_of_harmonic_series.py)
657661
* [Sumset](maths/sumset.py)
658662
* [Sylvester Sequence](maths/sylvester_sequence.py)
663+
* [Tanh](maths/tanh.py)
659664
* [Test Prime Check](maths/test_prime_check.py)
660665
* [Trapezoidal Rule](maths/trapezoidal_rule.py)
661666
* [Triplet Sum](maths/triplet_sum.py)
@@ -692,6 +697,8 @@
692697

693698
## Neural Network
694699
* [2 Hidden Layers Neural Network](neural_network/2_hidden_layers_neural_network.py)
700+
* Activation Functions
701+
* [Exponential Linear Unit](neural_network/activation_functions/exponential_linear_unit.py)
695702
* [Back Propagation Neural Network](neural_network/back_propagation_neural_network.py)
696703
* [Convolution Neural Network](neural_network/convolution_neural_network.py)
697704
* [Input Data](neural_network/input_data.py)
@@ -708,12 +715,15 @@
708715
* [Gauss Easter](other/gauss_easter.py)
709716
* [Graham Scan](other/graham_scan.py)
710717
* [Greedy](other/greedy.py)
718+
* [Guess The Number Search](other/guess_the_number_search.py)
719+
* [H Index](other/h_index.py)
711720
* [Least Recently Used](other/least_recently_used.py)
712721
* [Lfu Cache](other/lfu_cache.py)
713722
* [Linear Congruential Generator](other/linear_congruential_generator.py)
714723
* [Lru Cache](other/lru_cache.py)
715724
* [Magicdiamondpattern](other/magicdiamondpattern.py)
716725
* [Maximum Subarray](other/maximum_subarray.py)
726+
* [Maximum Subsequence](other/maximum_subsequence.py)
717727
* [Nested Brackets](other/nested_brackets.py)
718728
* [Password](other/password.py)
719729
* [Quine](other/quine.py)
@@ -1077,6 +1087,7 @@
10771087

10781088
## Sorts
10791089
* [Bead Sort](sorts/bead_sort.py)
1090+
* [Binary Insertion Sort](sorts/binary_insertion_sort.py)
10801091
* [Bitonic Sort](sorts/bitonic_sort.py)
10811092
* [Bogo Sort](sorts/bogo_sort.py)
10821093
* [Bubble Sort](sorts/bubble_sort.py)
@@ -1167,6 +1178,7 @@
11671178
* [Reverse Words](strings/reverse_words.py)
11681179
* [Snake Case To Camel Pascal Case](strings/snake_case_to_camel_pascal_case.py)
11691180
* [Split](strings/split.py)
1181+
* [String Switch Case](strings/string_switch_case.py)
11701182
* [Text Justification](strings/text_justification.py)
11711183
* [Top K Frequent Words](strings/top_k_frequent_words.py)
11721184
* [Upper](strings/upper.py)

boolean_algebra/and_gate.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ def test_and_gate() -> None:
4343

4444

4545
if __name__ == "__main__":
46+
test_and_gate()
47+
print(and_gate(1, 0))
4648
print(and_gate(0, 0))
4749
print(and_gate(0, 1))
4850
print(and_gate(1, 1))

cellular_automata/game_of_life.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
from matplotlib import pyplot as plt
3535
from matplotlib.colors import ListedColormap
3636

37-
usage_doc = "Usage of script: script_nama <size_of_canvas:int>"
37+
usage_doc = "Usage of script: script_name <size_of_canvas:int>"
3838

3939
choice = [0] * 100 + [1] * 10
4040
random.shuffle(choice)

ciphers/mixed_keyword_cypher.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,4 +65,5 @@ def mixed_keyword(key: str = "college", pt: str = "UNIVERSITY") -> str:
6565
return cypher
6666

6767

68-
print(mixed_keyword("college", "UNIVERSITY"))
68+
if __name__ == "__main__":
69+
print(mixed_keyword("college", "UNIVERSITY"))

conversions/prefix_conversions_string.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ def add_si_prefix(value: float) -> str:
9696
for name_prefix, value_prefix in prefixes.items():
9797
numerical_part = value / (10**value_prefix)
9898
if numerical_part > 1:
99-
return f"{str(numerical_part)} {name_prefix}"
99+
return f"{numerical_part!s} {name_prefix}"
100100
return str(value)
101101

102102

@@ -111,7 +111,7 @@ def add_binary_prefix(value: float) -> str:
111111
for prefix in BinaryUnit:
112112
numerical_part = value / (2**prefix.value)
113113
if numerical_part > 1:
114-
return f"{str(numerical_part)} {prefix.name}"
114+
return f"{numerical_part!s} {prefix.name}"
115115
return str(value)
116116

117117

conversions/rgb_hsv_conversion.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,8 @@ def rgb_to_hsv(red: int, green: int, blue: int) -> list[float]:
121121
float_red = red / 255
122122
float_green = green / 255
123123
float_blue = blue / 255
124-
value = max(max(float_red, float_green), float_blue)
125-
chroma = value - min(min(float_red, float_green), float_blue)
124+
value = max(float_red, float_green, float_blue)
125+
chroma = value - min(float_red, float_green, float_blue)
126126
saturation = 0 if value == 0 else chroma / value
127127

128128
if chroma == 0:

digital_image_processing/test_digital_image_processing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ def test_nearest_neighbour(
9696

9797

9898
def test_local_binary_pattern():
99-
file_path: str = "digital_image_processing/image_data/lena.jpg"
99+
file_path = "digital_image_processing/image_data/lena.jpg"
100100

101101
# Reading the image and converting it to grayscale.
102102
image = imread(file_path, 0)

divide_and_conquer/strassen_matrix_multiplication.py renamed to divide_and_conquer/strassen_matrix_multiplication.py.BROKEN

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ def strassen(matrix1: list, matrix2: list) -> list:
122122
if dimension1[0] == dimension1[1] and dimension2[0] == dimension2[1]:
123123
return [matrix1, matrix2]
124124

125-
maximum = max(max(dimension1), max(dimension2))
125+
maximum = max(dimension1, dimension2)
126126
maxim = int(math.pow(2, math.ceil(math.log2(maximum))))
127127
new_matrix1 = matrix1
128128
new_matrix2 = matrix2

dynamic_programming/fibonacci.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def get(self, index: int) -> list:
2424
return self.sequence[:index]
2525

2626

27-
def main():
27+
def main() -> None:
2828
print(
2929
"Fibonacci Series Using Dynamic Programming\n",
3030
"Enter the index of the Fibonacci number you want to calculate ",

0 commit comments

Comments
 (0)