aboutsummaryrefslogtreecommitdiff
path: root/challenge-113/abigail/lua/ch-2.lua
diff options
context:
space:
mode:
Diffstat (limited to 'challenge-113/abigail/lua/ch-2.lua')
-rw-r--r--challenge-113/abigail/lua/ch-2.lua25
1 files changed, 25 insertions, 0 deletions
diff --git a/challenge-113/abigail/lua/ch-2.lua b/challenge-113/abigail/lua/ch-2.lua
new file mode 100644
index 0000000000..15aac1ac2d
--- /dev/null
+++ b/challenge-113/abigail/lua/ch-2.lua
@@ -0,0 +1,25 @@
+#!/opt/local/bin/lua
+
+--
+-- See ../README.md
+--
+
+--
+-- Run as: lua ch-2.lua < input-file
+--
+
+for line in io . lines () do
+ local sum = 0
+ for n in line : gmatch ("[0-9]+")
+ do sum = sum + tonumber (n)
+ end
+ local c = 0
+ for n in line : gmatch ("[0-9]+")
+ do if c > 0
+ then io . write (" ")
+ end
+ c = c + 1
+ io . write (sum - n)
+ end
+ io . write ("\n")
+end