Set Mutations

  • + 0 comments

    Enter your code here. Read input from STDIN. Print output to STDOUT

    n = input() A = set(map(int, input().split())) num_other_sets = input() for _ in range(int(num_other_sets)): eachset = [input().split()[0], set(map(int, input().split()))] if eachset[0] == "update": A.update(eachset[1]) elif eachset[0] == "intersection_update": A.intersection_update(eachset[1]) elif eachset[0] == "symmetric_difference_update": A.symmetric_difference_update(eachset[1]) elif eachset[0] == "difference_update": A.difference_update(eachset[1])

    print(sum(A))