diff options
| author | Simon Green <mail@simon.green> | 2025-08-11 00:22:56 +1000 |
|---|---|---|
| committer | Simon Green <mail@simon.green> | 2025-08-11 00:22:56 +1000 |
| commit | 576c0a2b89712a98601c11f5233e65f5917ba34e (patch) | |
| tree | ebb9d653cad4f982d8773e3b5f158076c0e0eda2 /challenge-333/sgreen/python/ch-2.py | |
| parent | 085fd2e66487b2e1532ab0877919279f3f4c94e7 (diff) | |
| download | perlweeklychallenge-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-x | challenge-333/sgreen/python/ch-2.py | 25 |
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() |
