diff options
Diffstat (limited to 'challenge-012/zapwai/python/ch-2.py')
| -rw-r--r-- | challenge-012/zapwai/python/ch-2.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/challenge-012/zapwai/python/ch-2.py b/challenge-012/zapwai/python/ch-2.py new file mode 100644 index 0000000000..14580e9a23 --- /dev/null +++ b/challenge-012/zapwai/python/ch-2.py @@ -0,0 +1,19 @@ +import re +input = """/a/b/c/d +/a/b/cd +/a/b/cc +/a/b/c/d/e""" + +def proc(input): + line = input.split() + prefix = line[0] + cnt = 1 + while cnt > 0: + cnt = 0 + prefix = prefix[0:prefix.rindex("/")] + for i in range(len(line)): + if not re.search("^"+prefix+"\/", line[i]): + cnt += 1 + return prefix + +print(proc(input)) |
