diff options
| author | rir <rirans@comcast.net> | 2024-03-16 20:07:25 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-03-16 20:07:25 -0400 |
| commit | ff5e8ece15a2384fbfb530710f10aa485017d4a5 (patch) | |
| tree | 6fe268d9ceb2b25a2951ea984c077450feb2efae /challenge-260/luca-ferrari/python/ch-1.py | |
| parent | 60f1003122fbada697317d943c238593f86db579 (diff) | |
| parent | 62e7fc3bb85a74125663f4fbd0a5911f6f30c81f (diff) | |
| download | perlweeklychallenge-club-ff5e8ece15a2384fbfb530710f10aa485017d4a5.tar.gz perlweeklychallenge-club-ff5e8ece15a2384fbfb530710f10aa485017d4a5.tar.bz2 perlweeklychallenge-club-ff5e8ece15a2384fbfb530710f10aa485017d4a5.zip | |
Merge branch 'manwar:master' into work
Diffstat (limited to 'challenge-260/luca-ferrari/python/ch-1.py')
| -rw-r--r-- | challenge-260/luca-ferrari/python/ch-1.py | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/challenge-260/luca-ferrari/python/ch-1.py b/challenge-260/luca-ferrari/python/ch-1.py new file mode 100644 index 0000000000..8f70bb0494 --- /dev/null +++ b/challenge-260/luca-ferrari/python/ch-1.py @@ -0,0 +1,33 @@ +#!python + +# +# Perl Weekly Challenge 260 +# Task 1 +# +# See <https://perlweeklychallenge.org/blog/perl-weekly-challenge-260> +# + +import sys + +# task implementation +# the return value will be printed +def task_1( args ): + nums = list( map( int, args ) ) + bag = {} + + for n in nums: + occurrencies = len( list( filter( lambda x: x == n, nums ) ) ) + if not n in bag: + bag[ n ] = occurrencies + + + for o in bag.values(): + if len( list( filter( lambda x: x == o, bag.values() ) ) ) > 1: + return 0 + + return 1 + + +# invoke the main without the command itself +if __name__ == '__main__': + print( task_1( sys.argv[ 1: ] ) ) |
