aboutsummaryrefslogtreecommitdiff
path: root/challenge-110/abigail/lua/ch-1.lua
diff options
context:
space:
mode:
authorE7-87-83 <fungcheokyin@gmail.com>2021-05-02 21:12:39 +0800
committerE7-87-83 <fungcheokyin@gmail.com>2021-05-02 21:12:39 +0800
commit36318fa49b15eee8e9f9a66f03022009fdf12b99 (patch)
tree717885f56b22e69c0571a89eff554451685ca88a /challenge-110/abigail/lua/ch-1.lua
parentc6f8f5b8fc12980a57f4db78f1da65523ccce32f (diff)
parent14b2dabae68197e73c48121eb964de12e9ba9afc (diff)
downloadperlweeklychallenge-club-36318fa49b15eee8e9f9a66f03022009fdf12b99.tar.gz
perlweeklychallenge-club-36318fa49b15eee8e9f9a66f03022009fdf12b99.tar.bz2
perlweeklychallenge-club-36318fa49b15eee8e9f9a66f03022009fdf12b99.zip
Merge remote-tracking branch 'upstream/master' into newt
Diffstat (limited to 'challenge-110/abigail/lua/ch-1.lua')
-rw-r--r--challenge-110/abigail/lua/ch-1.lua24
1 files changed, 24 insertions, 0 deletions
diff --git a/challenge-110/abigail/lua/ch-1.lua b/challenge-110/abigail/lua/ch-1.lua
new file mode 100644
index 0000000000..a118074744
--- /dev/null
+++ b/challenge-110/abigail/lua/ch-1.lua
@@ -0,0 +1,24 @@
+#!/opt/local/bin/lua
+
+--
+-- See ../README.md
+--
+
+--
+-- Run as: lua ch-1.lua < input-file
+--
+
+for line in io . lines () do
+ local number = line : gsub (" ", "") -- Remove spaces
+ if -- nnnn nnnnnnnnnn
+ number : find ("^[0-9][0-9][0-9][0-9][0-9][0-9][0-9]" ..
+ "[0-9][0-9][0-9][0-9][0-9][0-9][0-9]$") or
+ -- +nn nnnnnnnnnn
+ number : find ("^%+[0-9][0-9][0-9][0-9][0-9]" ..
+ "[0-9][0-9][0-9][0-9][0-9][0-9][0-9]$") or
+ -- (nn) nnnnnnnnnn
+ number : find ("^%([0-9][0-9]%)[0-9][0-9][0-9]" ..
+ "[0-9][0-9][0-9][0-9][0-9][0-9][0-9]$")
+ then print (line)
+ end
+end