aboutsummaryrefslogtreecommitdiff
path: root/challenge-111/abigail/python/ch-2.py
diff options
context:
space:
mode:
authorRoger Bell_West <roger@firedrake.org>2021-05-05 09:05:19 +0100
committerRoger Bell_West <roger@firedrake.org>2021-05-05 09:05:19 +0100
commit87b5ebe9e07771cbb70cc569305e5b360afeedc0 (patch)
tree59a3bde53ee1def36c71c3598ff700bee5cc1017 /challenge-111/abigail/python/ch-2.py
parentc09c5e0af6d4d188a8877f153db6174398031f5f (diff)
parent5e66b581b9649e5bf461bc28bd391d25589e9258 (diff)
downloadperlweeklychallenge-club-87b5ebe9e07771cbb70cc569305e5b360afeedc0.tar.gz
perlweeklychallenge-club-87b5ebe9e07771cbb70cc569305e5b360afeedc0.tar.bz2
perlweeklychallenge-club-87b5ebe9e07771cbb70cc569305e5b360afeedc0.zip
Merge remote-tracking branch 'upstream/master'
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)