diff options
Diffstat (limited to 'challenge-182/lubos-kolouch/python')
| -rw-r--r-- | challenge-182/lubos-kolouch/python/ch-1.py | 10 | ||||
| -rw-r--r-- | challenge-182/lubos-kolouch/python/ch-2.py | 23 |
2 files changed, 33 insertions, 0 deletions
diff --git a/challenge-182/lubos-kolouch/python/ch-1.py b/challenge-182/lubos-kolouch/python/ch-1.py new file mode 100644 index 0000000000..373f34c2c8 --- /dev/null +++ b/challenge-182/lubos-kolouch/python/ch-1.py @@ -0,0 +1,10 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + + +def max_index(lst): + return lst.index(max(lst)) + + +print(max_index([5, 2, 9, 1, 7, 6])) # Output: 2 +print(max_index([4, 2, 3, 1, 5, 0])) # Output: 4 diff --git a/challenge-182/lubos-kolouch/python/ch-2.py b/challenge-182/lubos-kolouch/python/ch-2.py new file mode 100644 index 0000000000..2ebe227ab7 --- /dev/null +++ b/challenge-182/lubos-kolouch/python/ch-2.py @@ -0,0 +1,23 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + + +def common_path(paths): + paths = [path.split("/") for path in paths] + common = [] + for items in zip(*paths): + if all(item == items[0] for item in items): + common.append(items[0]) + else: + break + return "/".join(common) + + +paths = [ + "/a/b/c/1/x.pl", + "/a/b/c/d/e/2/x.pl", + "/a/b/c/d/3/x.pl", + "/a/b/c/4/x.pl", + "/a/b/c/d/5/x.pl", +] +print(common_path(paths)) # Output: /a/b/c |
