aboutsummaryrefslogtreecommitdiff
path: root/challenge-260/luca-ferrari/python/ch-1.py
blob: 8f70bb0494c9bd4d77612de80acdb8c4271764b1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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: ] ) )