aboutsummaryrefslogtreecommitdiff
path: root/challenge-135/abigail/lua/ch-1.lua
diff options
context:
space:
mode:
Diffstat (limited to 'challenge-135/abigail/lua/ch-1.lua')
-rw-r--r--challenge-135/abigail/lua/ch-1.lua27
1 files changed, 27 insertions, 0 deletions
diff --git a/challenge-135/abigail/lua/ch-1.lua b/challenge-135/abigail/lua/ch-1.lua
new file mode 100644
index 0000000000..b5db984457
--- /dev/null
+++ b/challenge-135/abigail/lua/ch-1.lua
@@ -0,0 +1,27 @@
+#!/opt/local/bin/lua
+
+--
+-- See ../README.md
+--
+
+--
+-- Run as: lua ch-1.lua < input-file
+--
+
+for line in io . lines () do
+ line = line : gsub ("^[-+]%s*", "")
+ if line : find ("%D") then
+ print ("not an integer")
+ else
+ if line : len () % 2 == 0 then
+ print ("even number of digits")
+ else
+ if line : len () < 3 then
+ print ("too short")
+ else
+ local start = 1 + (line : len () - 3) / 2
+ print (line : sub (start , start + 2))
+ end
+ end
+ end
+end