From 60c68b3209b3c09d3cbd29b4ef33080546a43fbd Mon Sep 17 00:00:00 2001 From: David Ferrone Date: Fri, 15 Mar 2024 11:21:15 -0400 Subject: Weekly Challenge Blast from the Past --- challenge-012/zapwai/python/ch-2.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 challenge-012/zapwai/python/ch-2.py (limited to 'challenge-012/zapwai/python/ch-2.py') 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)) -- cgit