diff options
| author | Luca Ferrari <fluca1978@gmail.com> | 2025-08-04 13:47:31 +0200 |
|---|---|---|
| committer | Luca Ferrari <fluca1978@gmail.com> | 2025-08-04 14:44:03 +0200 |
| commit | 0977e205540490c43e668474daf99abb688aa6f2 (patch) | |
| tree | 09d1faa953fe10c6f836582c2f5b4bbf0135e114 /challenge-333/luca-ferrari/python/ch-2.py | |
| parent | ce2f933a023e15e5dac73508e56a9aec0e87fae6 (diff) | |
| download | perlweeklychallenge-club-0977e205540490c43e668474daf99abb688aa6f2.tar.gz perlweeklychallenge-club-0977e205540490c43e668474daf99abb688aa6f2.tar.bz2 perlweeklychallenge-club-0977e205540490c43e668474daf99abb688aa6f2.zip | |
PWC 333
Task 1 Raku done
Task 2 Raku done
Task 1 PL/Perl done
Task 2 PL/Perl done
Task 1 PL/PgSQL done
Task 2 PL/PgSQL done
Task 1 PL/Java done
Task 2 PL/Java done
Task 1 Python done
Task 2 Python done
Diffstat (limited to 'challenge-333/luca-ferrari/python/ch-2.py')
| -rw-r--r-- | challenge-333/luca-ferrari/python/ch-2.py | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/challenge-333/luca-ferrari/python/ch-2.py b/challenge-333/luca-ferrari/python/ch-2.py new file mode 100644 index 0000000000..0d36552024 --- /dev/null +++ b/challenge-333/luca-ferrari/python/ch-2.py @@ -0,0 +1,37 @@ +#!python + +# +# Perl Weekly Challenge 333 +# Task 2 +# +# See <https://perlweeklychallenge.org/blog/perl-weekly-challenge-333> +# + +import sys + +# task implementation +# the return value will be printed +def task_2( args ): + result = [] + limit = len( args ) + index = 0 + + while limit > 0: + current = int( args[ index ] ) + index = index + 1 + result.append( current ) + limit = limit - 1 + if limit == 0: + break + + if current == 0: + result.append( current ) + limit = limit - 1 + if limit == 0: + break + + return result + +# invoke the main without the command itself +if __name__ == '__main__': + print( task_2( sys.argv[ 1: ] ) ) |
