forked from ayusharma/Hackerrank
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathset_dff.py
72 lines (49 loc) · 2.03 KB
/
set_dff.py
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
"""
Problem Statement
A-B.png.difference()
.difference() returns a set with all elements from set that are not in an iterable.
Sometimes '-' operator is used in place of .difference() operator but it operates only on the set of elements in set.
Set is immutable to .difference() operation (or '-' operation).
>>> s = set("Hacker")
>>> print s.difference("Rank")
set(['c', 'r', 'e', 'H'])
>>> print s.difference(set(['R', 'a', 'n', 'k']))
set(['c', 'r', 'e', 'H'])
>>> print s.difference(['R', 'a', 'n', 'k'])
set(['c', 'r', 'e', 'H'])
>>> print s.difference(enumerate(['R', 'a', 'n', 'k']))
set(['a', 'c', 'r', 'e', 'H', 'k'])
>>> print s.difference({"Rank":1})
set(['a', 'c', 'e', 'H', 'k', 'r'])
>>> s - set("Rank")
set(['H', 'c', 'r', 'e'])
Task
Students of District College have subscription of English and French newspapers. Some students have subscribed to only English, some have subscribed to only French and some have subscribed to both newspapers.
You are given two sets of roll numbers of students, who have subscribed to English and French newspapers. Your task is to find total number of students who have subscribed to only English newspapers.
Input Format
First line contains, number of students who have subscribed to English newspaper.
Second line contains, space separated list of roll numbers of students, who have subscribed to English newspaper.
Third line contains, number of students who have subscribed to French newspaper.
Fourth line contains, space separated list of roll numbers of students, who have subscribed to French newspaper.
Constraints
0<Total number of students in college<1000
Output Format
Output total number of students who have only English newspaper subscriptions.
Sample Input
9
1 2 3 4 5 6 7 8 9
9
10 1 2 3 11 21 55 6 8
Sample Output
4
Explanation
Roll numbers of students who have only English newspaper subscription:
4, 5, 7 and 9.
Hence, total is 4 students.
"""
e = input()
el = set(map(int,raw_input().split()))
f = input()
fl = set(map(int,raw_input().split()))
diff = el.difference(fl)
print len(diff)