# 뉴스 클러스터링 - 프로그래머스
def solution(str1, str2):
str1 = str1.upper()
str2 = str2.upper()
m1, m2 = [], []
for i in range(len(str1) - 1):
if 65 <= ord(str1[i]) <= 90 and 65 <= ord(str1[i + 1]) <= 90:
m1.append(str1[i] + str1[i + 1])
for i in range(len(str2) - 1):
if 65 <= ord(str2[i]) <= 90 and 65 <= ord(str2[i + 1]) <= 90:
m2.append(str2[i] + str2[i + 1])
intersect = 0
tmp = m2[:]
for ele in m1:
if ele in m2:
m2.remove(ele)
intersect += 1
m2 = tmp
union = len(m1) + len(m2) - intersect
if not union:
return 65536
similar = intersect / union
return int(similar * 65536)