From 5017aa2d94ee2daee1db83ece00d4efc34bc8576 Mon Sep 17 00:00:00 2001 From: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> Date: Fri, 9 Oct 2020 15:03:51 +0000 Subject: [PATCH 1/4] updating DIRECTORY.md --- DIRECTORY.md | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/DIRECTORY.md b/DIRECTORY.md index d3a378c3a2ee..80859356cca9 100644 --- a/DIRECTORY.md +++ b/DIRECTORY.md @@ -473,6 +473,7 @@ * [Binary Exponentiation 2](https://github.com/TheAlgorithms/Python/blob/master/other/binary_exponentiation_2.py) * [Detecting English Programmatically](https://github.com/TheAlgorithms/Python/blob/master/other/detecting_english_programmatically.py) * [Dijkstra Bankers Algorithm](https://github.com/TheAlgorithms/Python/blob/master/other/dijkstra_bankers_algorithm.py) + * [Doomsday](https://github.com/TheAlgorithms/Python/blob/master/other/doomsday.py) * [Euclidean Gcd](https://github.com/TheAlgorithms/Python/blob/master/other/euclidean_gcd.py) * [Fischer Yates Shuffle](https://github.com/TheAlgorithms/Python/blob/master/other/fischer_yates_shuffle.py) * [Frequency Finder](https://github.com/TheAlgorithms/Python/blob/master/other/frequency_finder.py) @@ -487,6 +488,7 @@ * [Lru Cache](https://github.com/TheAlgorithms/Python/blob/master/other/lru_cache.py) * [Magicdiamondpattern](https://github.com/TheAlgorithms/Python/blob/master/other/magicdiamondpattern.py) * [Markov Chain](https://github.com/TheAlgorithms/Python/blob/master/other/markov_chain.py) + * [Max Sum Sliding Window](https://github.com/TheAlgorithms/Python/blob/master/other/max_sum_sliding_window.py) * [Nested Brackets](https://github.com/TheAlgorithms/Python/blob/master/other/nested_brackets.py) * [Palindrome](https://github.com/TheAlgorithms/Python/blob/master/other/palindrome.py) * [Password Generator](https://github.com/TheAlgorithms/Python/blob/master/other/password_generator.py) @@ -529,7 +531,6 @@ * [Sol2](https://github.com/TheAlgorithms/Python/blob/master/project_euler/problem_06/sol2.py) * [Sol3](https://github.com/TheAlgorithms/Python/blob/master/project_euler/problem_06/sol3.py) * [Sol4](https://github.com/TheAlgorithms/Python/blob/master/project_euler/problem_06/sol4.py) - * [Test Solutions](https://github.com/TheAlgorithms/Python/blob/master/project_euler/problem_06/test_solutions.py) * Problem 07 * [Sol1](https://github.com/TheAlgorithms/Python/blob/master/project_euler/problem_07/sol1.py) * [Sol2](https://github.com/TheAlgorithms/Python/blob/master/project_euler/problem_07/sol2.py) @@ -595,11 +596,11 @@ * Problem 26 * [Sol1](https://github.com/TheAlgorithms/Python/blob/master/project_euler/problem_26/sol1.py) * Problem 27 - * [Problem 27 Sol1](https://github.com/TheAlgorithms/Python/blob/master/project_euler/problem_27/problem_27_sol1.py) + * [Sol1](https://github.com/TheAlgorithms/Python/blob/master/project_euler/problem_27/sol1.py) * Problem 28 * [Sol1](https://github.com/TheAlgorithms/Python/blob/master/project_euler/problem_28/sol1.py) * Problem 29 - * [Solution](https://github.com/TheAlgorithms/Python/blob/master/project_euler/problem_29/solution.py) + * [Sol1](https://github.com/TheAlgorithms/Python/blob/master/project_euler/problem_29/sol1.py) * Problem 30 * [Sol1](https://github.com/TheAlgorithms/Python/blob/master/project_euler/problem_30/sol1.py) * Problem 31 @@ -656,6 +657,8 @@ * [Sol1](https://github.com/TheAlgorithms/Python/blob/master/project_euler/problem_63/sol1.py) * Problem 67 * [Sol1](https://github.com/TheAlgorithms/Python/blob/master/project_euler/problem_67/sol1.py) + * Problem 71 + * [Sol1](https://github.com/TheAlgorithms/Python/blob/master/project_euler/problem_71/sol1.py) * Problem 76 * [Sol1](https://github.com/TheAlgorithms/Python/blob/master/project_euler/problem_76/sol1.py) * Problem 97 From 1144496b2e49333285e7ebdda5903875778ea5fb Mon Sep 17 00:00:00 2001 From: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> Date: Sat, 10 Oct 2020 08:56:33 +0000 Subject: [PATCH 2/4] updating DIRECTORY.md --- DIRECTORY.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/DIRECTORY.md b/DIRECTORY.md index b57cb2eb131b..f13e2718e698 100644 --- a/DIRECTORY.md +++ b/DIRECTORY.md @@ -558,6 +558,8 @@ * [Sol2](https://github.com/TheAlgorithms/Python/blob/master/project_euler/problem_12/sol2.py) * Problem 120 * [Sol1](https://github.com/TheAlgorithms/Python/blob/master/project_euler/problem_120/sol1.py) + * Problem 125 + * [Sol1](https://github.com/TheAlgorithms/Python/blob/master/project_euler/problem_125/sol1.py) * Problem 13 * [Sol1](https://github.com/TheAlgorithms/Python/blob/master/project_euler/problem_13/sol1.py) * Problem 14 From 44fafd9e2d85c92e8ca28d22689ae5bd2689f0b1 Mon Sep 17 00:00:00 2001 From: jenia90 Date: Sat, 10 Oct 2020 12:14:53 +0300 Subject: [PATCH 3/4] Added type hints to blockchain algorithms --- blockchain/chinese_remainder_theorem.py | 8 ++++---- blockchain/diophantine_equation.py | 8 ++++---- blockchain/modular_division.py | 12 ++++++------ 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/blockchain/chinese_remainder_theorem.py b/blockchain/chinese_remainder_theorem.py index b6a486f0b1ed..3e4b2b7b4f10 100644 --- a/blockchain/chinese_remainder_theorem.py +++ b/blockchain/chinese_remainder_theorem.py @@ -12,7 +12,7 @@ # Extended Euclid -def extended_euclid(a, b): +def extended_euclid(a: int, b: int) -> (int, int): """ >>> extended_euclid(10, 6) (-1, 2) @@ -29,7 +29,7 @@ def extended_euclid(a, b): # Uses ExtendedEuclid to find inverses -def chinese_remainder_theorem(n1, r1, n2, r2): +def chinese_remainder_theorem(n1: int, r1: int, n2: int, r2: int) -> int: """ >>> chinese_remainder_theorem(5,1,7,3) 31 @@ -51,7 +51,7 @@ def chinese_remainder_theorem(n1, r1, n2, r2): # ----------SAME SOLUTION USING InvertModulo instead ExtendedEuclid---------------- # This function find the inverses of a i.e., a^(-1) -def invert_modulo(a, n): +def invert_modulo(a: int, n: int) -> int: """ >>> invert_modulo(2, 5) 3 @@ -67,7 +67,7 @@ def invert_modulo(a, n): # Same a above using InvertingModulo -def chinese_remainder_theorem2(n1, r1, n2, r2): +def chinese_remainder_theorem2(n1: int, r1: int, n2: int, r2: int) -> int: """ >>> chinese_remainder_theorem2(5,1,7,3) 31 diff --git a/blockchain/diophantine_equation.py b/blockchain/diophantine_equation.py index 751b0efb7227..a92c2a13cfd5 100644 --- a/blockchain/diophantine_equation.py +++ b/blockchain/diophantine_equation.py @@ -5,7 +5,7 @@ # GCD ( Greatest Common Divisor ) or HCF ( Highest Common Factor ) -def diophantine(a, b, c): +def diophantine(a: int, b: int, c: int) -> (int, int): """ >>> diophantine(10,6,14) (-7.0, 14.0) @@ -37,7 +37,7 @@ def diophantine(a, b, c): # n is the number of solution you want, n = 2 by default -def diophantine_all_soln(a, b, c, n=2): +def diophantine_all_soln(a: int, b: int, c: int, n: int = 2) -> None: """ >>> diophantine_all_soln(10, 6, 14) -7.0 14.0 @@ -72,7 +72,7 @@ def diophantine_all_soln(a, b, c, n=2): # Euclid's Algorithm -def greatest_common_divisor(a, b): +def greatest_common_divisor(a: int, b: int) -> int: """ >>> greatest_common_divisor(7,5) 1 @@ -98,7 +98,7 @@ def greatest_common_divisor(a, b): # x and y, then d = gcd(a,b) -def extended_gcd(a, b): +def extended_gcd(a: int, b: int) -> (int, int, int): """ >>> extended_gcd(10, 6) (2, -1, 2) diff --git a/blockchain/modular_division.py b/blockchain/modular_division.py index 8fcf6e37cbed..e012db28fab8 100644 --- a/blockchain/modular_division.py +++ b/blockchain/modular_division.py @@ -14,7 +14,7 @@ # Uses ExtendedEuclid to find the inverse of a -def modular_division(a, b, n): +def modular_division(a: int, b: int, n: int) -> int: """ >>> modular_division(4,8,5) 2 @@ -33,7 +33,7 @@ def modular_division(a, b, n): # This function find the inverses of a i.e., a^(-1) -def invert_modulo(a, n): +def invert_modulo(a: int, n: int) -> int: """ >>> invert_modulo(2, 5) 3 @@ -51,7 +51,7 @@ def invert_modulo(a, n): # ------------------ Finding Modular division using invert_modulo ------------------- # This function used the above inversion of a to find x = (b*a^(-1))mod n -def modular_division2(a, b, n): +def modular_division2(a: int, b: int, n: int) -> int: """ >>> modular_division2(4,8,5) 2 @@ -72,7 +72,7 @@ def modular_division2(a, b, n): # and y, then d = gcd(a,b) -def extended_gcd(a, b): +def extended_gcd(a: int, b: int) -> (int, int, int): """ >>> extended_gcd(10, 6) (2, -1, 2) @@ -99,7 +99,7 @@ def extended_gcd(a, b): # Extended Euclid -def extended_euclid(a, b): +def extended_euclid(a: int, b: int) -> (int, int): """ >>> extended_euclid(10, 6) (-1, 2) @@ -119,7 +119,7 @@ def extended_euclid(a, b): # Euclid's Algorithm -def greatest_common_divisor(a, b): +def greatest_common_divisor(a: int, b: int) -> int: """ >>> greatest_common_divisor(7,5) 1 From 11cb77469cf8f1d0cca7ebd2aa5a7839a59a7243 Mon Sep 17 00:00:00 2001 From: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> Date: Thu, 15 Oct 2020 17:20:48 +0000 Subject: [PATCH 4/4] updating DIRECTORY.md --- DIRECTORY.md | 28 ---------------------------- 1 file changed, 28 deletions(-) diff --git a/DIRECTORY.md b/DIRECTORY.md index 220a1a226107..2cf51f8c4beb 100644 --- a/DIRECTORY.md +++ b/DIRECTORY.md @@ -684,34 +684,6 @@ * [Sol1](https://github.com/TheAlgorithms/Python/blob/master/project_euler/problem_120/sol1.py) * Problem 125 * [Sol1](https://github.com/TheAlgorithms/Python/blob/master/project_euler/problem_125/sol1.py) - * Problem 13 - * [Sol1](https://github.com/TheAlgorithms/Python/blob/master/project_euler/problem_13/sol1.py) - * Problem 14 - * [Sol1](https://github.com/TheAlgorithms/Python/blob/master/project_euler/problem_14/sol1.py) - * [Sol2](https://github.com/TheAlgorithms/Python/blob/master/project_euler/problem_14/sol2.py) - * Problem 15 - * [Sol1](https://github.com/TheAlgorithms/Python/blob/master/project_euler/problem_15/sol1.py) - * Problem 16 - * [Sol1](https://github.com/TheAlgorithms/Python/blob/master/project_euler/problem_16/sol1.py) - * [Sol2](https://github.com/TheAlgorithms/Python/blob/master/project_euler/problem_16/sol2.py) - * Problem 17 - * [Sol1](https://github.com/TheAlgorithms/Python/blob/master/project_euler/problem_17/sol1.py) - * Problem 18 - * [Solution](https://github.com/TheAlgorithms/Python/blob/master/project_euler/problem_18/solution.py) - * Problem 19 - * [Sol1](https://github.com/TheAlgorithms/Python/blob/master/project_euler/problem_19/sol1.py) - * Problem 20 - * [Sol1](https://github.com/TheAlgorithms/Python/blob/master/project_euler/problem_20/sol1.py) - * [Sol2](https://github.com/TheAlgorithms/Python/blob/master/project_euler/problem_20/sol2.py) - * [Sol3](https://github.com/TheAlgorithms/Python/blob/master/project_euler/problem_20/sol3.py) - * [Sol4](https://github.com/TheAlgorithms/Python/blob/master/project_euler/problem_20/sol4.py) - * Problem 21 - * [Sol1](https://github.com/TheAlgorithms/Python/blob/master/project_euler/problem_21/sol1.py) - * Problem 22 - * [Sol1](https://github.com/TheAlgorithms/Python/blob/master/project_euler/problem_22/sol1.py) - * [Sol2](https://github.com/TheAlgorithms/Python/blob/master/project_euler/problem_22/sol2.py) - * Problem 23 - * [Sol1](https://github.com/TheAlgorithms/Python/blob/master/project_euler/problem_23/sol1.py) * Problem 173 * [Sol1](https://github.com/TheAlgorithms/Python/blob/master/project_euler/problem_173/sol1.py) * Problem 191