aboutsummaryrefslogtreecommitdiff
path: root/challenge-111/abigail/python/ch-2.py
diff options
context:
space:
mode:
authorMohammad S Anwar <Mohammad.Anwar@yahoo.com>2021-05-04 21:14:59 +0100
committerGitHub <noreply@github.com>2021-05-04 21:14:59 +0100
commit4f6bea99af9e40ddc033f3fc34f762266731c827 (patch)
tree4311bce3734c03c43fdb9694dce6ed230a626b1a /challenge-111/abigail/python/ch-2.py
parenta636015eef980dbc91fa8216f0cfb942ceaad11a (diff)
parent74e93b7c85b2797a877de91fe9e6eb3ad59c9650 (diff)
downloadperlweeklychallenge-club-4f6bea99af9e40ddc033f3fc34f762266731c827.tar.gz
perlweeklychallenge-club-4f6bea99af9e40ddc033f3fc34f762266731c827.tar.bz2
perlweeklychallenge-club-4f6bea99af9e40ddc033f3fc34f762266731c827.zip
Merge pull request #4017 from Abigail/abigail/week-111
Abigail/week 111
Diffstat (limited to 'challenge-111/abigail/python/ch-2.py')
-rw-r--r--challenge-111/abigail/python/ch-2.py35
1 files changed, 35 insertions, 0 deletions
diff --git a/challenge-111/abigail/python/ch-2.py b/challenge-111/abigail/python/ch-2.py
new file mode 100644
index 0000000000..ce79d6b393
--- /dev/null
+++ b/challenge-111/abigail/python/ch-2.py
@@ -0,0 +1,35 @@
+#!/opt/local/bin/python
+
+#
+# See ../README.md
+#
+
+#
+# Run as: python ch-2.py < input-file
+#
+
+import fileinput
+import string
+import re
+
+
+#
+# Create a pattern which matches words with their characters in lexical order.
+#
+pat = "^"
+for x in list (string . ascii_lowercase):
+ pat = pat + x + "*"
+pat += "$"
+
+
+#
+# Match strings with their characters in lexical order, and remember
+# the longest of them.
+#
+longest = ""
+for line in fileinput . input ():
+ line = line . strip ()
+ if re . match (pat, line . lower ()) and len (line) > len (longest):
+ longest = line
+
+print (longest)