From 4699f600935129b16a48074d8534411ce935db17 Mon Sep 17 00:00:00 2001 From: Abigail Date: Mon, 3 Jan 2022 12:25:51 +0100 Subject: Week 146 Part 1 is a fixed output challenge, so, just a glorified Hello World program. It's stolen from project Euler, task 7. --- challenge-146/abigail/python/ch-2.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 challenge-146/abigail/python/ch-2.py (limited to 'challenge-146/abigail/python/ch-2.py') 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 ("") -- cgit