aboutsummaryrefslogtreecommitdiff
path: root/challenge-115/stuart-little/lua/ch-1.lua
blob: 9e995c679131c67ecc91fe95b35754e2c223b184 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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)