You are viewing a single comment's thread. Return to all 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))
Seems like cookies are disabled on this browser, please enable them to open this website
Set Mutations
You are viewing a single comment's thread. Return to all 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))