aboutsummaryrefslogtreecommitdiff
path: root/challenge-115/stuart-little/lua/ch-1.lua
diff options
context:
space:
mode:
Diffstat (limited to 'challenge-115/stuart-little/lua/ch-1.lua')
-rwxr-xr-xchallenge-115/stuart-little/lua/ch-1.lua20
1 files changed, 20 insertions, 0 deletions
diff --git a/challenge-115/stuart-little/lua/ch-1.lua b/challenge-115/stuart-little/lua/ch-1.lua
new file mode 100755
index 0000000000..9e995c6791
--- /dev/null
+++ b/challenge-115/stuart-little/lua/ch-1.lua
@@ -0,0 +1,20 @@
+#!/usr/bin/env lua
+
+-- run <script> <space-separated strings>
+
+t={}
+
+for _,s in ipairs(arg) do
+ t[s:sub(1,1)] = (t[s:sub(1,1)] or 0)+1
+ t[s:sub(-1)] = (t[s:sub(-1)] or 0)-1
+end
+
+for _,v in pairs(t) do
+ if v ~= 0 then
+ print(0)
+ os.exit()
+ end
+end
+
+print((#arg < 2) and 0 or 1)
+