aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHVukman <peterslopp@googlemail.com>2025-08-08 17:40:02 +0200
committerGitHub <noreply@github.com>2025-08-08 17:40:02 +0200
commit3de48fb7d924191619907307a35a4aee89441c49 (patch)
tree58641bb535673dcbc3e029c04fc4af9ceffe1f8a
parentdaa35d6745d3f1519aab69c3e42ec269ebb5e108 (diff)
downloadperlweeklychallenge-club-3de48fb7d924191619907307a35a4aee89441c49.tar.gz
perlweeklychallenge-club-3de48fb7d924191619907307a35a4aee89441c49.tar.bz2
perlweeklychallenge-club-3de48fb7d924191619907307a35a4aee89441c49.zip
Create 333_p2.lua
-rw-r--r--challenge-333/hvukman/lua/333_p2.lua27
1 files changed, 27 insertions, 0 deletions
diff --git a/challenge-333/hvukman/lua/333_p2.lua b/challenge-333/hvukman/lua/333_p2.lua
new file mode 100644
index 0000000000..7fe02a96b7
--- /dev/null
+++ b/challenge-333/hvukman/lua/333_p2.lua
@@ -0,0 +1,27 @@
+-- insert in res while res<=x
+function Dup2(x)
+ local len = #x
+ local res = {}
+ for l,v in ipairs(x) do
+
+ if v == 0 then
+ table.insert(res,0)
+ if #res >= len then break end
+ table.insert(res,0)
+ else
+ table.insert(res,v)
+ end
+ if #res >= len then break end
+ end
+
+ for k,m in ipairs(res) do
+ io.write (m," ")
+ end
+ io.write ("\n")
+end
+
+Dup2({ 1; 0; 2; 3; 0; 4; 5; 0})
+Dup2({ 1;2;3})
+Dup2({ 1;2;3;0})
+Dup2({ 0;0;1;2})
+Dup2({ 1;2;0;3;4})