-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathintersection.py
More file actions
38 lines (29 loc) · 907 Bytes
/
intersection.py
File metadata and controls
38 lines (29 loc) · 907 Bytes
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
## Use intersection to find out whether two strings share the same substring(s)
##############################
## First, some basic things ##
##############################
# map two strings
a = map(str, input())
b = map(str, input())
# intersect a and b
d = set(a).intersection(b)
# if the length of c is greater than 0, print "Yes" - a and b share the same substring(s). Otherwise, print "No".
if len(d) > 0:
print "Yes"
else:
print "No"
######################################################
## We can write a function to accommodate the above ##
######################################################
def intersect():
a = map(str, raw_input())
b = map(str, raw_input())
d = set(a).intersection(b)
if len(d) > 0:
print "YES"
else:
print "NO"
## call the function intersct for multiple times
c = int(input())
for _ in range(c):
intersect()