aboutsummaryrefslogtreecommitdiff
path: root/challenge-111/abigail/lua/ch-2.lua
diff options
context:
space:
mode:
Diffstat (limited to 'challenge-111/abigail/lua/ch-2.lua')
-rw-r--r--challenge-111/abigail/lua/ch-2.lua25
1 files changed, 25 insertions, 0 deletions
diff --git a/challenge-111/abigail/lua/ch-2.lua b/challenge-111/abigail/lua/ch-2.lua
new file mode 100644
index 0000000000..6beeb6a979
--- /dev/null
+++ b/challenge-111/abigail/lua/ch-2.lua
@@ -0,0 +1,25 @@
+#!/opt/local/bin/lua
+
+--
+-- See ../README.md
+--
+
+--
+-- Run as: lua ch-2.lua < input-file
+--
+
+local longest = ""
+
+for line in io . lines () do
+ --
+ -- Find words with their letters in lexical order, and which are
+ -- longer than the longest found so far.
+ --
+ if line : lower ()
+ : find ("^a*b*c*d*e*f*g*i*j*k*l*m*n*o*p*q*r*s*t*u*v*w*x*y*z*$")
+ and line : len () > longest : len ()
+ then longest = line
+ end
+end
+
+print (longest)