diff options
| author | Mohammad Sajid Anwar <Mohammad.Anwar@yahoo.com> | 2023-12-27 11:28:19 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-12-27 11:28:19 +0000 |
| commit | 4ece120b2f4c7b25b00eaad66524fb5d99fa58c3 (patch) | |
| tree | 7306628eec352a2a4873762a037e126b727b94bc /challenge-249/luca-ferrari/python/ch-1.py | |
| parent | f9c0e59d3367bff903bf51e82768c336783103d9 (diff) | |
| parent | 3e655a098886fc8d97d1bb333236e989e892616c (diff) | |
| download | perlweeklychallenge-club-4ece120b2f4c7b25b00eaad66524fb5d99fa58c3.tar.gz perlweeklychallenge-club-4ece120b2f4c7b25b00eaad66524fb5d99fa58c3.tar.bz2 perlweeklychallenge-club-4ece120b2f4c7b25b00eaad66524fb5d99fa58c3.zip | |
Merge pull request #9303 from fluca1978/PWC249
PWC 249
Diffstat (limited to 'challenge-249/luca-ferrari/python/ch-1.py')
| -rw-r--r-- | challenge-249/luca-ferrari/python/ch-1.py | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/challenge-249/luca-ferrari/python/ch-1.py b/challenge-249/luca-ferrari/python/ch-1.py new file mode 100644 index 0000000000..229e3e2a00 --- /dev/null +++ b/challenge-249/luca-ferrari/python/ch-1.py @@ -0,0 +1,34 @@ +#!python + +# +# Perl Weekly Challenge 249 +# Task 1 +# +# See <https://perlweeklychallenge.org/blog/perl-weekly-challenge-249/> +# + +import sys + +# task implementation +def main( argv ): + classification = {} + for i in argv: + if not i in classification: + classification[ i ] = 0 + classification[ i ] += 1 + + pairs = [] + for k in classification: + while classification[ k ] >= 2: + pairs.append( [ k, k ] ) + classification[ k ] -= 2 + + for p in pairs: + print( ", ".join( p ) ) + + +# invoke the main without the command itself +if __name__ == '__main__': + main( sys.argv[ 1: ] ) + + |
