aboutsummaryrefslogtreecommitdiff
path: root/challenge-106/stuart-little/lua/ch-1.lua
diff options
context:
space:
mode:
Diffstat (limited to 'challenge-106/stuart-little/lua/ch-1.lua')
-rwxr-xr-xchallenge-106/stuart-little/lua/ch-1.lua16
1 files changed, 16 insertions, 0 deletions
diff --git a/challenge-106/stuart-little/lua/ch-1.lua b/challenge-106/stuart-little/lua/ch-1.lua
new file mode 100755
index 0000000000..71c5eacbab
--- /dev/null
+++ b/challenge-106/stuart-little/lua/ch-1.lua
@@ -0,0 +1,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))