aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xchallenge-110/stuart-little/python/ch-1.py23
-rwxr-xr-xchallenge-110/stuart-little/python/ch-2.py21
2 files changed, 44 insertions, 0 deletions
diff --git a/challenge-110/stuart-little/python/ch-1.py b/challenge-110/stuart-little/python/ch-1.py
new file mode 100755
index 0000000000..1287c19b6f
--- /dev/null
+++ b/challenge-110/stuart-little/python/ch-1.py
@@ -0,0 +1,23 @@
+#!/usr/bin/env python
+
+# run <script> <path-to-file or nothing>
+# defaults to challenge sample if no file is entered
+
+import re
+import sys
+
+if (len(sys.argv)>1):
+ with open(sys.argv[1]) as f:
+ data=f.read()
+else:
+ data="""
+0044 1148820341
+ +44 1148820341
+ 44-11-4882-0341
+(44) 1148820341
+ 00 1148820341
+"""
+rgx=re.compile(r'((?:\+\d{2}|\(\d{2}\)|\d{4})\s+\d{10})')
+nrs=re.findall(rgx,data)
+for nr in nrs:
+ print(nr)
diff --git a/challenge-110/stuart-little/python/ch-2.py b/challenge-110/stuart-little/python/ch-2.py
new file mode 100755
index 0000000000..7c92a1ae8d
--- /dev/null
+++ b/challenge-110/stuart-little/python/ch-2.py
@@ -0,0 +1,21 @@
+#!/usr/bin/env python
+
+# run <script> <path-to-file or nothing>
+# defaults to challenge sample if no file is entered
+
+import sys
+
+if (len(sys.argv)>1):
+ with open(sys.argv[1]) as f:
+ data=f.read()
+else:
+ data="""name,age,sex
+Mohammad,45,m
+Joe,20,m
+Julie,35,f
+Cristina,10,f
+"""
+
+transpLines = list(map(lambda x: ','.join(x), list(zip(*list(map(lambda x: x.split(','),data.splitlines()))))))
+for ln in transpLines:
+ print(ln)