-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathset_difference.py
More file actions
21 lines (17 loc) · 1.06 KB
/
set_difference.py
File metadata and controls
21 lines (17 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/bin/python3
# Set .difference() Operation Challenge Solution
# problem link: https://www.hackerrank.com/challenges/py-set-difference-operation/problem
# Author: Audity Ghosh
# Date: 30 January 2020
# Description:
# This script calculates the total number of students who have subscribed to only the
# English newspaper using the set .difference() operation.
# Enter your code here. Read input from STDIN. Print output to STDOUT
n = int(input()) # Read number of students who subscribed to the English newspaper
data1 = set(list(map(int, input().split(' ')))) # Roll numbers of students subscribed to English newspaper
t = int(input()) # Read number of students who subscribed to the French newspaper
data2 = set(list(map(int, input().split(' ')))) # Roll numbers of students subscribed to French newspaper
# Find the difference between the English and French subscription sets (students subscribed only to English)
s = set(data1.difference(data2))
# Output the total number of students who have subscriptions to only the English newspaper
print(len(s))