aboutsummaryrefslogtreecommitdiff
path: root/challenge-146/abigail/python/ch-2.py
diff options
context:
space:
mode:
authorMohammad S Anwar <Mohammad.Anwar@yahoo.com>2022-01-04 21:18:09 +0000
committerGitHub <noreply@github.com>2022-01-04 21:18:09 +0000
commitd1581f755d50e5b3a5ccf74a25280f39caa809fc (patch)
tree14d50cbd3a19dddf06cb89f16ea57155024e1da6 /challenge-146/abigail/python/ch-2.py
parentd8abd054e8e70147188d2b57c922ba092e2aecff (diff)
parent41c3d16c97874e85d25f28d37e59df3e2d9a9d66 (diff)
downloadperlweeklychallenge-club-d1581f755d50e5b3a5ccf74a25280f39caa809fc.tar.gz
perlweeklychallenge-club-d1581f755d50e5b3a5ccf74a25280f39caa809fc.tar.bz2
perlweeklychallenge-club-d1581f755d50e5b3a5ccf74a25280f39caa809fc.zip
Merge pull request #5463 from Abigail/abigail/week-146
Week 146
Diffstat (limited to 'challenge-146/abigail/python/ch-2.py')
-rw-r--r--challenge-146/abigail/python/ch-2.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/challenge-146/abigail/python/ch-2.py b/challenge-146/abigail/python/ch-2.py
new file mode 100644
index 0000000000..bf3f380742
--- /dev/null
+++ b/challenge-146/abigail/python/ch-2.py
@@ -0,0 +1,24 @@
+#!/opt/local/bin/python
+
+#
+# See ../README.md
+#
+
+#
+# Run as: python ch-2.py < input-file
+#
+
+import fileinput
+import sys
+
+for line in fileinput . input ():
+ a, b = map (lambda x: int (x), line . strip () . split ("/"))
+ for i in range (2):
+ if a < b:
+ b = b - a
+ else:
+ a = a - b
+ if a == 0 or b == 0:
+ break
+ sys . stdout . write ("{:}/{:} " . format (a, b))
+ print ("")