Set Mutations

  • + 0 comments

    set_a_count = int(input()) set_a = set(map(int,input().split())) n = int(input()) for i in range (n): operation = input().split() set_b = set(map(int,input().split())) if operation[0] == "update": set_a.update(set_b) elif operation[0] == "intersection_update": set_a.intersection_update(set_b) elif operation[0] == "difference_update": set_a.difference_update(set_b) else: set_a.symmetric_difference_update(set_b)

    print(sum(set_a))