aboutsummaryrefslogtreecommitdiff
path: root/challenge-146/abigail/python
diff options
context:
space:
mode:
authorAbigail <abigail@abigail.freedom.nl>2022-01-03 12:25:51 +0100
committerAbigail <abigail@abigail.freedom.nl>2022-01-03 16:14:38 +0100
commit4699f600935129b16a48074d8534411ce935db17 (patch)
tree1ff6170ab68961c4d133c8a975b8323e7f2b5ed4 /challenge-146/abigail/python
parent41f8dae6667e8b4215b9f2507d7a2e14236890b9 (diff)
downloadperlweeklychallenge-club-4699f600935129b16a48074d8534411ce935db17.tar.gz
perlweeklychallenge-club-4699f600935129b16a48074d8534411ce935db17.tar.bz2
perlweeklychallenge-club-4699f600935129b16a48074d8534411ce935db17.zip
Week 146
Part 1 is a fixed output challenge, so, just a glorified Hello World program. It's stolen from project Euler, task 7.
Diffstat (limited to 'challenge-146/abigail/python')
-rw-r--r--challenge-146/abigail/python/ch-1.py11
-rw-r--r--challenge-146/abigail/python/ch-2.py24
2 files changed, 35 insertions, 0 deletions
diff --git a/challenge-146/abigail/python/ch-1.py b/challenge-146/abigail/python/ch-1.py
new file mode 100644
index 0000000000..b82ae3bd95
--- /dev/null
+++ b/challenge-146/abigail/python/ch-1.py
@@ -0,0 +1,11 @@
+#!/opt/local/bin/python
+
+#
+# See ../README.md
+#
+
+#
+# Run as: python ch-1.py
+#
+
+print ("104743") \ No newline at end of file
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 ("")