aboutsummaryrefslogtreecommitdiff
path: root/challenge-146/abigail/python/ch-2.py
diff options
context:
space:
mode:
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 ("")