aboutsummaryrefslogtreecommitdiff
path: root/challenge-145/lubos-kolouch/python
diff options
context:
space:
mode:
authorLubos Kolouch <lubos@kolouch.net>2023-07-08 12:33:49 +0200
committerLubos Kolouch <lubos@kolouch.net>2023-07-08 12:33:49 +0200
commit393d8f7b2cc5cb6fa63fd185b730a61173e452a4 (patch)
tree241f38bc2d9f556c2392ff351d55129f45978252 /challenge-145/lubos-kolouch/python
parent3599200121ce36f3e5f6560835fc3d1ba22961e4 (diff)
downloadperlweeklychallenge-club-393d8f7b2cc5cb6fa63fd185b730a61173e452a4.tar.gz
perlweeklychallenge-club-393d8f7b2cc5cb6fa63fd185b730a61173e452a4.tar.bz2
perlweeklychallenge-club-393d8f7b2cc5cb6fa63fd185b730a61173e452a4.zip
feat(challenge-145/lubos-kolouch/perl,python/): Challenge 145 LK Perl Python
Diffstat (limited to 'challenge-145/lubos-kolouch/python')
-rw-r--r--challenge-145/lubos-kolouch/python/ch-1.py11
-rw-r--r--challenge-145/lubos-kolouch/python/ch-2.py21
2 files changed, 32 insertions, 0 deletions
diff --git a/challenge-145/lubos-kolouch/python/ch-1.py b/challenge-145/lubos-kolouch/python/ch-1.py
new file mode 100644
index 0000000000..bcd2e57de6
--- /dev/null
+++ b/challenge-145/lubos-kolouch/python/ch-1.py
@@ -0,0 +1,11 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+
+def dot_product(a, b):
+ return sum(x * y for x, y in zip(a, b))
+
+
+a = [1, 2, 3]
+b = [4, 5, 6]
+print(dot_product(a, b)) # Output: 32
diff --git a/challenge-145/lubos-kolouch/python/ch-2.py b/challenge-145/lubos-kolouch/python/ch-2.py
new file mode 100644
index 0000000000..7a9584b223
--- /dev/null
+++ b/challenge-145/lubos-kolouch/python/ch-2.py
@@ -0,0 +1,21 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+
+def palindromic_tree(s):
+ result = []
+ for i in range(len(s)):
+ for j in range(i + 1, len(s) + 1):
+ substring = s[i:j]
+ if substring == substring[::-1]:
+ result.append(substring)
+ return result
+
+
+s = "redivider"
+print(
+ palindromic_tree(s)
+) # Output: ['r', 'redivider', 'e', 'edivide', 'd', 'divid', 'i', 'ivi', 'v']
+
+s = "deific"
+print(palindromic_tree(s)) # Output: ['d', 'e', 'i', 'ifi', 'f', 'c']