aboutsummaryrefslogtreecommitdiff
path: root/challenge-145/sgreen/python/ch-2.py
diff options
context:
space:
mode:
authorMohammad S Anwar <Mohammad.Anwar@yahoo.com>2022-01-02 14:34:00 +0000
committerGitHub <noreply@github.com>2022-01-02 14:34:00 +0000
commit171592004a80dc30e8d1d1d35fd82a9c9681a724 (patch)
tree0ea7a2b1349848d076454cc973e59d21c53e8cba /challenge-145/sgreen/python/ch-2.py
parentdb0755b8dd9daa003523cbcd53759ced09ae7dfd (diff)
parent8bdcc1eac06889402d8b9beb3f1e7c467df9a4ff (diff)
downloadperlweeklychallenge-club-171592004a80dc30e8d1d1d35fd82a9c9681a724.tar.gz
perlweeklychallenge-club-171592004a80dc30e8d1d1d35fd82a9c9681a724.tar.bz2
perlweeklychallenge-club-171592004a80dc30e8d1d1d35fd82a9c9681a724.zip
Merge pull request #5445 from simongreen-net/master
sgreen solutions to challenge 145
Diffstat (limited to 'challenge-145/sgreen/python/ch-2.py')
-rwxr-xr-xchallenge-145/sgreen/python/ch-2.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/challenge-145/sgreen/python/ch-2.py b/challenge-145/sgreen/python/ch-2.py
new file mode 100755
index 0000000000..65ed569178
--- /dev/null
+++ b/challenge-145/sgreen/python/ch-2.py
@@ -0,0 +1,27 @@
+#!/usr/bin/env python
+
+import sys
+
+
+def main(word):
+ strings = []
+
+ # Make the starting point from each character
+ for i in range(len(word)):
+
+ # And the end point
+ for j in range(i, len(word)):
+
+ # This is string we will examine
+ s = word[i:j + 1]
+
+ # If we don't already know about it, and it's palindromic, add
+ # it to the string array
+ if s not in strings and s == s[::-1]:
+ strings.append(s)
+
+ print(*strings, sep=' ')
+
+
+if __name__ == '__main__':
+ main(sys.argv[1])