aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAbigail <abigail@abigail.be>2021-04-28 19:29:23 +0200
committerAbigail <abigail@abigail.be>2021-04-28 19:29:23 +0200
commit2b7dcae3794ff4ff32819db0094152c53e9a568c (patch)
treeeea32f9ea0e6b8b0c7e374183115c18463c5e7a8
parent5581b0741dada9a8f9035a950a0e98626b56f629 (diff)
downloadperlweeklychallenge-club-2b7dcae3794ff4ff32819db0094152c53e9a568c.tar.gz
perlweeklychallenge-club-2b7dcae3794ff4ff32819db0094152c53e9a568c.tar.bz2
perlweeklychallenge-club-2b7dcae3794ff4ff32819db0094152c53e9a568c.zip
Python solution for week 110, part 1
-rw-r--r--challenge-110/abigail/README.md1
-rw-r--r--challenge-110/abigail/python/ch-1.py19
2 files changed, 20 insertions, 0 deletions
diff --git a/challenge-110/abigail/README.md b/challenge-110/abigail/README.md
index 10c12592fa..e1a9a3d534 100644
--- a/challenge-110/abigail/README.md
+++ b/challenge-110/abigail/README.md
@@ -47,6 +47,7 @@ can completly ignore any white space in the input.
[Lua](lua/ch-1.lua)
[Node.js](node/ch-1.js)
[Perl](perl/ch-1.pl)
+[Python](python/ch-1.py)
### Blog
diff --git a/challenge-110/abigail/python/ch-1.py b/challenge-110/abigail/python/ch-1.py
new file mode 100644
index 0000000000..63e3c8e69e
--- /dev/null
+++ b/challenge-110/abigail/python/ch-1.py
@@ -0,0 +1,19 @@
+#!/opt/local/bin/python
+
+#
+# See ../README.md
+#
+
+#
+# Run as: python ch-1.py < input-file
+#
+
+import fileinput
+import re
+
+for line in fileinput . input ():
+ plain = re . sub (r'\s+', "", line) # Strip whitespace
+ plain = re . sub (r'^\+', "00", plain) # Replace leading +
+ plain = re . sub (r'^\([0-9][0-9]\)', "0000", plain) # Replace leading (NN)
+ if re . search (r'^[0-9]{14}$', plain): # Chech for 14 digits
+ print (line, end = '')