From fa2fd3cc8679d7044491c3c173e7ed01a49b2960 Mon Sep 17 00:00:00 2001 From: KerimovEmil Date: Wed, 27 Jun 2018 22:44:56 -0400 Subject: [PATCH 1/4] Adding Python 3 euclidean example --- .../code/python3/euclidean_example.py | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 chapters/euclidean_algorithm/code/python3/euclidean_example.py diff --git a/chapters/euclidean_algorithm/code/python3/euclidean_example.py b/chapters/euclidean_algorithm/code/python3/euclidean_example.py new file mode 100644 index 000000000..d4993e193 --- /dev/null +++ b/chapters/euclidean_algorithm/code/python3/euclidean_example.py @@ -0,0 +1,28 @@ +# submitted by KerimovEmil +def euclid_mod(a, b): + + a = abs(a) + b = abs(b) + + while b > 0: + a, b = b, a % b + + return a + + +def euclid_sub(a, b): + + a = abs(a) + b = abs(b) + + while a != b: + if a > b: + a = a - b + else: + b = b - a + + return a + + +print(euclid_mod(64 * 67, 64 * 81)) +print(euclid_sub(128 * 12, 128 * 77)) From 652e73592d4883662e59896a9f6f6dbd5526a6e4 Mon Sep 17 00:00:00 2001 From: KerimovEmil Date: Wed, 27 Jun 2018 22:53:15 -0400 Subject: [PATCH 2/4] Adding name to contributor list --- CONTRIBUTORS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index a1ad4161d..2f1f64218 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -5,3 +5,4 @@ Gathros Jeremie Gillet (- Jie -) Salim Khatib Hitesh C +Emil Kerimov From 46f647892235833c8c6fdd002664e945681facaf Mon Sep 17 00:00:00 2001 From: KerimovEmil Date: Thu, 28 Jun 2018 18:43:05 -0400 Subject: [PATCH 3/4] Addressing code review of removing the extra line after the function name. Not sure what the conclusion of https://github.com/algorithm-archivists/algorithm-archive/issues/141 will be, but it seems like python 3 will be staying. --- chapters/euclidean_algorithm/code/python2/euclidean_example.py | 2 -- chapters/euclidean_algorithm/code/python3/euclidean_example.py | 2 -- 2 files changed, 4 deletions(-) diff --git a/chapters/euclidean_algorithm/code/python2/euclidean_example.py b/chapters/euclidean_algorithm/code/python2/euclidean_example.py index 709e59a77..d41e7d94d 100644 --- a/chapters/euclidean_algorithm/code/python2/euclidean_example.py +++ b/chapters/euclidean_algorithm/code/python2/euclidean_example.py @@ -1,5 +1,4 @@ def euclid_mod(a, b): - a = abs(a) b = abs(b) temp = 0 @@ -12,7 +11,6 @@ def euclid_mod(a, b): return a def euclid_sub(a, b): - a = abs(a) b = abs(b) diff --git a/chapters/euclidean_algorithm/code/python3/euclidean_example.py b/chapters/euclidean_algorithm/code/python3/euclidean_example.py index d4993e193..63e087d62 100644 --- a/chapters/euclidean_algorithm/code/python3/euclidean_example.py +++ b/chapters/euclidean_algorithm/code/python3/euclidean_example.py @@ -1,6 +1,5 @@ # submitted by KerimovEmil def euclid_mod(a, b): - a = abs(a) b = abs(b) @@ -11,7 +10,6 @@ def euclid_mod(a, b): def euclid_sub(a, b): - a = abs(a) b = abs(b) From 965082f71539ca036a2a21f2bdaedc1cb8ce9dcf Mon Sep 17 00:00:00 2001 From: KerimovEmil Date: Sat, 30 Jun 2018 11:14:55 -0400 Subject: [PATCH 4/4] Addressing code review of removing python 2 and renaming to python --- .../{python3 => python}/euclidean_example.py | 0 .../code/python2/euclidean_example.py | 27 ------------------- 2 files changed, 27 deletions(-) rename chapters/euclidean_algorithm/code/{python3 => python}/euclidean_example.py (100%) delete mode 100644 chapters/euclidean_algorithm/code/python2/euclidean_example.py diff --git a/chapters/euclidean_algorithm/code/python3/euclidean_example.py b/chapters/euclidean_algorithm/code/python/euclidean_example.py similarity index 100% rename from chapters/euclidean_algorithm/code/python3/euclidean_example.py rename to chapters/euclidean_algorithm/code/python/euclidean_example.py diff --git a/chapters/euclidean_algorithm/code/python2/euclidean_example.py b/chapters/euclidean_algorithm/code/python2/euclidean_example.py deleted file mode 100644 index d41e7d94d..000000000 --- a/chapters/euclidean_algorithm/code/python2/euclidean_example.py +++ /dev/null @@ -1,27 +0,0 @@ -def euclid_mod(a, b): - a = abs(a) - b = abs(b) - temp = 0 - - while b > 0: - temp = b - b = a % b - a = temp - - return a - -def euclid_sub(a, b): - a = abs(a) - b = abs(b) - - while a != b: - if a > b: - a = a - b - else: - b = b - a - - return a - -print euclid_mod(64 * 67, 64 * 81) -print euclid_sub(128 * 12, 128 * 77) -