aboutsummaryrefslogtreecommitdiff
path: root/challenge-146/abigail/python/ch-2.py
blob: bf3f38074272386b89d9ed55ee5153c51d04726e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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 ("")