aboutsummaryrefslogtreecommitdiff
path: root/challenge-252/deadmarshal/lua/ch-2.lua
diff options
context:
space:
mode:
authorMohammad Sajid Anwar <Mohammad.Anwar@yahoo.com>2024-01-21 17:57:17 +0000
committerGitHub <noreply@github.com>2024-01-21 17:57:17 +0000
commit0cc193c86d63fb566b88a2d447147faa95b2715e (patch)
treeae4bf5763997749e4a6543f602bc7ef7f248deb7 /challenge-252/deadmarshal/lua/ch-2.lua
parent77f823797c2b56f60f7429970826c5f006072193 (diff)
parent6a30f27182af9a9ae0ce1a671bc49d2065a8164b (diff)
downloadperlweeklychallenge-club-0cc193c86d63fb566b88a2d447147faa95b2715e.tar.gz
perlweeklychallenge-club-0cc193c86d63fb566b88a2d447147faa95b2715e.tar.bz2
perlweeklychallenge-club-0cc193c86d63fb566b88a2d447147faa95b2715e.zip
Merge pull request #9434 from deadmarshal/TWC252
TWC252
Diffstat (limited to 'challenge-252/deadmarshal/lua/ch-2.lua')
-rw-r--r--challenge-252/deadmarshal/lua/ch-2.lua15
1 files changed, 15 insertions, 0 deletions
diff --git a/challenge-252/deadmarshal/lua/ch-2.lua b/challenge-252/deadmarshal/lua/ch-2.lua
new file mode 100644
index 0000000000..15c8c85bd6
--- /dev/null
+++ b/challenge-252/deadmarshal/lua/ch-2.lua
@@ -0,0 +1,15 @@
+#!usr/bin/env lua
+
+local function unique_sum_zero(n)
+ local ret = {}
+ for i=1,n//2 do
+ ret[#ret+1] = i
+ ret[#ret+1] = -i
+ end
+ if n % 2 == 1 then ret[#ret+1] = 0 end
+ return ret
+end
+
+print(table.unpack(unique_sum_zero(5)))
+print(table.unpack(unique_sum_zero(3)))
+print(table.unpack(unique_sum_zero(1)))