-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy path1_find_intersection.py
More file actions
35 lines (26 loc) · 875 Bytes
/
1_find_intersection.py
File metadata and controls
35 lines (26 loc) · 875 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
def FindIntersection(strArr):
# Format into int sets
mystrings = strArr.strip('"]["').replace(" ","").split('","')
first, second = [set(map(int, mystring.split(","))) for mystring in mystrings]
# Get intersection
return list(first & second)
print(FindIntersection(input()))
# Test Input:
# ["1, 3, 4, 7, 13", "1, 2, 4, 13, 15"]
# TODO:
# This works locally running Python 3.8!
# But somehow this doesn't work on the Coderbyte site - test cases and possibly running the code seems to
# do a list conversion in the background when using Python 3 - this should not be happening 🤔
# Test Input:
# ["1, 3, 4, 7, 13", "1, 2, 4, 13, 15"]
# # Pi WIP
# def FindIntersection(strArr):
#
# [a, b] = [set(s.split(", ")) for s in strArr]
#
# return ",".join(a & b)
#
# print(FindIntersection(input()))
#
#
# #return ",".join(sorted(a & b, key=int))