aboutsummaryrefslogtreecommitdiff
path: root/challenge-117/stuart-little/lua/ch-1.lua
diff options
context:
space:
mode:
Diffstat (limited to 'challenge-117/stuart-little/lua/ch-1.lua')
-rwxr-xr-xchallenge-117/stuart-little/lua/ch-1.lua11
1 files changed, 11 insertions, 0 deletions
diff --git a/challenge-117/stuart-little/lua/ch-1.lua b/challenge-117/stuart-little/lua/ch-1.lua
new file mode 100755
index 0000000000..790f7332ca
--- /dev/null
+++ b/challenge-117/stuart-little/lua/ch-1.lua
@@ -0,0 +1,11 @@
+#!/usr/bin/env lua
+
+-- run <script> <path-to-file>
+
+sm,nrln=0,0
+for ln in io.lines(arg[1]) do
+ nr = ln:match("[^%d]*(%d+)")
+ sm = sm + nr
+ nrln = nrln+1
+end
+print(("%d"):format((nrln+1)*(nrln+2)/2 - sm))