aboutsummaryrefslogtreecommitdiff
path: root/challenge-240/deadmarshal/lua/ch-2.lua
diff options
context:
space:
mode:
Diffstat (limited to 'challenge-240/deadmarshal/lua/ch-2.lua')
-rw-r--r--challenge-240/deadmarshal/lua/ch-2.lua12
1 files changed, 12 insertions, 0 deletions
diff --git a/challenge-240/deadmarshal/lua/ch-2.lua b/challenge-240/deadmarshal/lua/ch-2.lua
new file mode 100644
index 0000000000..79141e0303
--- /dev/null
+++ b/challenge-240/deadmarshal/lua/ch-2.lua
@@ -0,0 +1,12 @@
+#!/usr/bin/env lua
+
+local function build_array(t)
+ assert(type(t) == 'table','t must be a table!')
+ local ret = {}
+ for i=1,#t do ret[i] = t[t[i]+1] end
+ return ret
+end
+
+print(table.unpack(build_array{0,2,1,5,3,4}))
+print(table.unpack(build_array{5,0,1,2,3,4}))
+