diff options
| author | Mohammad S Anwar <Mohammad.Anwar@yahoo.com> | 2022-01-04 21:18:09 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-01-04 21:18:09 +0000 |
| commit | d1581f755d50e5b3a5ccf74a25280f39caa809fc (patch) | |
| tree | 14d50cbd3a19dddf06cb89f16ea57155024e1da6 /challenge-146/abigail/python | |
| parent | d8abd054e8e70147188d2b57c922ba092e2aecff (diff) | |
| parent | 41c3d16c97874e85d25f28d37e59df3e2d9a9d66 (diff) | |
| download | perlweeklychallenge-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')
| -rw-r--r-- | challenge-146/abigail/python/ch-1.py | 11 | ||||
| -rw-r--r-- | challenge-146/abigail/python/ch-2.py | 24 |
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 ("") |
