Created
January 1, 2018 12:32
-
-
Save amulyakashyap09/1da090712077657e16ce29f1bcc59d9a to your computer and use it in GitHub Desktop.
mutations.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
length=int(input()) | |
s=set(map(int, input().split())) | |
N=int(input()) | |
for i in range(N): | |
(p, q)=input().split() | |
s2=set(map(int, input().split())) | |
if p=='intersection_update': | |
s.intersection_update(s2) | |
elif p=='update': | |
s.update(s2) | |
elif p=='symmetric_difference_update': | |
s.symmetric_difference_update(s2) | |
elif p=='difference_update': | |
s.difference_update(s2) | |
print(sum(s)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment