From 99063b5fc5d819c88e31fc89281c86a61af23bf7 Mon Sep 17 00:00:00 2001 From: aryan1165 Date: Wed, 27 Sep 2023 18:13:55 +0530 Subject: [PATCH 1/4] Deleted euclidean_gcd.py. Fixes#8063 --- maths/euclidean_gcd.py | 47 ------------------------------------------ 1 file changed, 47 deletions(-) delete mode 100644 maths/euclidean_gcd.py diff --git a/maths/euclidean_gcd.py b/maths/euclidean_gcd.py deleted file mode 100644 index de4b250243db..000000000000 --- a/maths/euclidean_gcd.py +++ /dev/null @@ -1,47 +0,0 @@ -""" https://en.wikipedia.org/wiki/Euclidean_algorithm """ - - -def euclidean_gcd(a: int, b: int) -> int: - """ - Examples: - >>> euclidean_gcd(3, 5) - 1 - - >>> euclidean_gcd(6, 3) - 3 - """ - while b: - a, b = b, a % b - return a - - -def euclidean_gcd_recursive(a: int, b: int) -> int: - """ - Recursive method for euclicedan gcd algorithm - - Examples: - >>> euclidean_gcd_recursive(3, 5) - 1 - - >>> euclidean_gcd_recursive(6, 3) - 3 - """ - return a if b == 0 else euclidean_gcd_recursive(b, a % b) - - -def main(): - print(f"euclidean_gcd(3, 5) = {euclidean_gcd(3, 5)}") - print(f"euclidean_gcd(5, 3) = {euclidean_gcd(5, 3)}") - print(f"euclidean_gcd(1, 3) = {euclidean_gcd(1, 3)}") - print(f"euclidean_gcd(3, 6) = {euclidean_gcd(3, 6)}") - print(f"euclidean_gcd(6, 3) = {euclidean_gcd(6, 3)}") - - print(f"euclidean_gcd_recursive(3, 5) = {euclidean_gcd_recursive(3, 5)}") - print(f"euclidean_gcd_recursive(5, 3) = {euclidean_gcd_recursive(5, 3)}") - print(f"euclidean_gcd_recursive(1, 3) = {euclidean_gcd_recursive(1, 3)}") - print(f"euclidean_gcd_recursive(3, 6) = {euclidean_gcd_recursive(3, 6)}") - print(f"euclidean_gcd_recursive(6, 3) = {euclidean_gcd_recursive(6, 3)}") - - -if __name__ == "__main__": - main() From ed586327b8b536cc98a03116d4d8e5b8c34715fb Mon Sep 17 00:00:00 2001 From: aryan1165 Date: Thu, 28 Sep 2023 15:11:43 +0530 Subject: [PATCH 2/4] Fixes #9014 --- data_structures/arrays/permutations.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data_structures/arrays/permutations.py b/data_structures/arrays/permutations.py index 0f029187b92b..2baef9e66f38 100644 --- a/data_structures/arrays/permutations.py +++ b/data_structures/arrays/permutations.py @@ -10,7 +10,7 @@ def permute_recursive(nums: list[int]) -> list[list[int]]: return [[]] for _ in range(len(nums)): n = nums.pop(0) - permutations = permute_recursive(nums) + permutations = permute_recursive(nums.copy()) for perm in permutations: perm.append(n) result.extend(permutations) From 798a3c3a56fdff0e0823da1b84adbe218e06c209 Mon Sep 17 00:00:00 2001 From: aryan1165 Date: Thu, 28 Sep 2023 16:58:56 +0530 Subject: [PATCH 3/4] Revert "Fixes #9014" This reverts commit ed586327b8b536cc98a03116d4d8e5b8c34715fb. Reverting this commit as it is not merged --- data_structures/arrays/permutations.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data_structures/arrays/permutations.py b/data_structures/arrays/permutations.py index 2baef9e66f38..0f029187b92b 100644 --- a/data_structures/arrays/permutations.py +++ b/data_structures/arrays/permutations.py @@ -10,7 +10,7 @@ def permute_recursive(nums: list[int]) -> list[list[int]]: return [[]] for _ in range(len(nums)): n = nums.pop(0) - permutations = permute_recursive(nums.copy()) + permutations = permute_recursive(nums) for perm in permutations: perm.append(n) result.extend(permutations) From 700c54335ff444319ad1accebafcd3812b3b4ab3 Mon Sep 17 00:00:00 2001 From: aryan1165 Date: Thu, 28 Sep 2023 17:05:07 +0530 Subject: [PATCH 4/4] Revert "Revert "Fixes #9014"" This reverts commit 798a3c3a56fdff0e0823da1b84adbe218e06c209. --- data_structures/arrays/permutations.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data_structures/arrays/permutations.py b/data_structures/arrays/permutations.py index 0f029187b92b..2baef9e66f38 100644 --- a/data_structures/arrays/permutations.py +++ b/data_structures/arrays/permutations.py @@ -10,7 +10,7 @@ def permute_recursive(nums: list[int]) -> list[list[int]]: return [[]] for _ in range(len(nums)): n = nums.pop(0) - permutations = permute_recursive(nums) + permutations = permute_recursive(nums.copy()) for perm in permutations: perm.append(n) result.extend(permutations)