diff options
| author | James Smith <js5@sanger.ac.uk> | 2022-12-30 12:40:51 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-12-30 12:40:51 +0000 |
| commit | 45c6d0058689532f7a3742339a676d23a8193e50 (patch) | |
| tree | 45b005a7da55416c73afdceed8780447db8205ce /challenge-197/deadmarshal/lua/ch-1.lua | |
| parent | 4f4f3e92ae4f200f5ca209dd57348a99cf386aa3 (diff) | |
| parent | ef1b6e72f5f8b7b06df4f7f955522b0eb7f554fd (diff) | |
| download | perlweeklychallenge-club-45c6d0058689532f7a3742339a676d23a8193e50.tar.gz perlweeklychallenge-club-45c6d0058689532f7a3742339a676d23a8193e50.tar.bz2 perlweeklychallenge-club-45c6d0058689532f7a3742339a676d23a8193e50.zip | |
Merge branch 'manwar:master' into master
Diffstat (limited to 'challenge-197/deadmarshal/lua/ch-1.lua')
| -rw-r--r-- | challenge-197/deadmarshal/lua/ch-1.lua | 16 |
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}),' ')) + |
