diff options
| author | Roger Bell_West <roger@firedrake.org> | 2021-04-26 14:17:55 +0100 |
|---|---|---|
| committer | Roger Bell_West <roger@firedrake.org> | 2021-04-26 14:17:55 +0100 |
| commit | b1b52f1c2205682f9bf4477d5232a460d5fe8a58 (patch) | |
| tree | f183fe6ad951a930f9eeb0fa25c9101e6f2dd63b /challenge-110/roger-bell-west/python | |
| parent | 1ff197d81f941c3dd35d77bec8a0326807e8d2b1 (diff) | |
| download | perlweeklychallenge-club-b1b52f1c2205682f9bf4477d5232a460d5fe8a58.tar.gz perlweeklychallenge-club-b1b52f1c2205682f9bf4477d5232a460d5fe8a58.tar.bz2 perlweeklychallenge-club-b1b52f1c2205682f9bf4477d5232a460d5fe8a58.zip | |
Solutions for challenge #110
Diffstat (limited to 'challenge-110/roger-bell-west/python')
| -rwxr-xr-x | challenge-110/roger-bell-west/python/ch-1.py | 10 | ||||
| -rwxr-xr-x | challenge-110/roger-bell-west/python/ch-2.py | 16 |
2 files changed, 26 insertions, 0 deletions
diff --git a/challenge-110/roger-bell-west/python/ch-1.py b/challenge-110/roger-bell-west/python/ch-1.py new file mode 100755 index 0000000000..ff7e397315 --- /dev/null +++ b/challenge-110/roger-bell-west/python/ch-1.py @@ -0,0 +1,10 @@ +#! /usr/bin/python3 + +import fileinput +import re + +pn=re.compile("^ *(\+[0-9]{2}|\([0-9]{2}\)|[0-9]{4}) [0-9]{10} *$") +for line in fileinput.input(): + line=line.rstrip() + if re.match(pn,line): + print(line) diff --git a/challenge-110/roger-bell-west/python/ch-2.py b/challenge-110/roger-bell-west/python/ch-2.py new file mode 100755 index 0000000000..5ee699e520 --- /dev/null +++ b/challenge-110/roger-bell-west/python/ch-2.py @@ -0,0 +1,16 @@ +#! /usr/bin/python + +import fileinput + +a=[] + +for line in fileinput.input(): + line=line.rstrip() + r=line.split(',') + for ci in range(len(r)): + while len(a) < ci+1: + a.append([]) + a[ci].append(r[ci]) + +for r in a: + print (','.join(r)) |
