Link : programmers.co.kr/learn/courses/30/lessons/17677
Python
더보기
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
|
def intersection(list1, list2):
stack = []
for i in list1:
if i in list2:
stack.append(i)
list2.remove(i)
return stack
def union(list1, list2):
return list1 + list2
def solution(str1, str2):
str1 = str1.lower()
str2 = str2.lower()
data1 = list()
data2 = list()
for i in range(0, len(str1) - 1):
if 'a' <= str1[i] <= 'z' and 'a' <= str1[i + 1] <= 'z':
data1.append(str1[i:i + 2])
for i in range(0, len(str2) - 1):
if 'a' <= str2[i] <= 'z' and 'a' <= str2[i + 1] <= 'z':
data2.append(str2[i:i + 2])
inter_data = intersection(data1, data2)
total_data = union(data1, data2)
if len(total_data) > 0:
return int(len(inter_data) / len(total_data) * 65536)
else:
return 65536
|
cs |
FeedBack
cjw.git@gmail.com
'알고리즘 > 소스코드' 카테고리의 다른 글
PROGRAMMERS 42888: 오픈채팅방 (0) | 2021.01.13 |
---|---|
PROGRAMMERS 17679: [1차] 프렌즈4블록 (0) | 2021.01.13 |
PROGRAMMERS 12973: 짝지어 제거하기 (0) | 2021.01.11 |
PROGRAMMERS 43163: 단어 변환 (0) | 2021.01.11 |
PROGRAMMERS 42746: 가장 큰 수 (0) | 2021.01.11 |
댓글