aboutsummaryrefslogtreecommitdiff
path: root/challenge-333/sgreen/python/ch-2.py
diff options
context:
space:
mode:
authorSimon Green <mail@simon.green>2025-08-11 00:22:56 +1000
committerSimon Green <mail@simon.green>2025-08-11 00:22:56 +1000
commit576c0a2b89712a98601c11f5233e65f5917ba34e (patch)
treeebb9d653cad4f982d8773e3b5f158076c0e0eda2 /challenge-333/sgreen/python/ch-2.py
parent085fd2e66487b2e1532ab0877919279f3f4c94e7 (diff)
downloadperlweeklychallenge-club-576c0a2b89712a98601c11f5233e65f5917ba34e.tar.gz
perlweeklychallenge-club-576c0a2b89712a98601c11f5233e65f5917ba34e.tar.bz2
perlweeklychallenge-club-576c0a2b89712a98601c11f5233e65f5917ba34e.zip
sgreen solutions to challenge 333
Diffstat (limited to 'challenge-333/sgreen/python/ch-2.py')
-rwxr-xr-xchallenge-333/sgreen/python/ch-2.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/challenge-333/sgreen/python/ch-2.py b/challenge-333/sgreen/python/ch-2.py
new file mode 100755
index 0000000000..f0662513ed
--- /dev/null
+++ b/challenge-333/sgreen/python/ch-2.py
@@ -0,0 +1,25 @@
+#!/usr/bin/env python3
+
+import sys
+
+
+def duplicate_zeros(ints: list) -> list:
+ solution = []
+ for i in ints:
+ if i == 0:
+ # Duplicate the zero
+ solution.append(0)
+ solution.append(i)
+
+ return solution[:len(ints)]
+
+
+def main():
+ # Convert input into integers
+ array = [int(n) for n in sys.argv[1:]]
+ result = duplicate_zeros(array)
+ print(result)
+
+
+if __name__ == '__main__':
+ main()