-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathset_intersection.py
More file actions
21 lines (17 loc) · 1.03 KB
/
set_intersection.py
File metadata and controls
21 lines (17 loc) · 1.03 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 .intersection() Operation Challenge Solution
# problem link: https://www.hackerrank.com/challenges/py-set-intersection-operation/problem
# Author: Audity Ghosh
# Date: 30 January 2020
# Description:
# This script calculates the total number of students who have subscribed to both
# the English and French newspapers using the set .intersection() operation.
# Enter your code here. Read input from STDIN. Print output to STDOUT
n = int(input()) # Read number of students who subscribed to 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 French newspaper
data2 = set(list(map(int, input().split(' ')))) # Roll numbers of students subscribed to French newspaper
# Find the intersection of both sets (students subscribed to both newspapers)
s = set(data1.intersection(data2))
# Output the total number of students who have subscriptions to both newspapers
print(len(s))