aboutsummaryrefslogtreecommitdiff
path: root/challenge-197/deadmarshal/lua/ch-1.lua
diff options
context:
space:
mode:
authordeadmarshal <adeadmarshal@gmail.com>2022-12-28 10:47:13 +0330
committerdeadmarshal <adeadmarshal@gmail.com>2022-12-28 10:47:13 +0330
commit977802cd25bb919bbc0bad828d014a68fc7bab17 (patch)
treef997db1a859bf124b7ab22248a0c4a4974d610a7 /challenge-197/deadmarshal/lua/ch-1.lua
parent9720dd7a3a5d6c22d6cc034c363d1d09e309e745 (diff)
downloadperlweeklychallenge-club-977802cd25bb919bbc0bad828d014a68fc7bab17.tar.gz
perlweeklychallenge-club-977802cd25bb919bbc0bad828d014a68fc7bab17.tar.bz2
perlweeklychallenge-club-977802cd25bb919bbc0bad828d014a68fc7bab17.zip
TWC197
Diffstat (limited to 'challenge-197/deadmarshal/lua/ch-1.lua')
-rw-r--r--challenge-197/deadmarshal/lua/ch-1.lua16
1 files changed, 16 insertions, 0 deletions
diff --git a/challenge-197/deadmarshal/lua/ch-1.lua b/challenge-197/deadmarshal/lua/ch-1.lua
new file mode 100644
index 0000000000..2fbf3434ff
--- /dev/null
+++ b/challenge-197/deadmarshal/lua/ch-1.lua
@@ -0,0 +1,16 @@
+local function move_zero(t)
+ local ret,count = {},0
+ for i=1,#t do
+ if t[i] ~= 0 then ret[#ret+1] = t[i]
+ else count = count + 1 end
+ end
+ for i=1,count do
+ ret[#ret+1] = 0
+ end
+ return ret
+end
+
+print(table.concat(move_zero({1,0,3,0,0,5}),' '))
+print(table.concat(move_zero({1,6,4}),' '))
+print(table.concat(move_zero({0,1,0,2,0}),' '))
+