aboutsummaryrefslogtreecommitdiff
path: root/challenge-106/stuart-little/lua/ch-1.lua
blob: 71c5eacbab07e026ec7c05b6b03be7458af17478 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#!/usr/bin/env lua

-- run <script> <space-separated numbers>

t={}
for _,v in ipairs(arg) do
   table.insert(t,v)
end
table.sort(t)
maxDiff=0
for k,v in ipairs(t) do
   if (t[k+1] and t[k+1]-t[k] > maxDiff) then
      maxDiff = t[k+1]-t[k]
   end
end
print(("%d"):format(maxDiff))