import math
def make_set(word):
word = word.upper() # 모두 대문자로 변환
a = []
b = []
english = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"]
for i in range(len(word)-1):
a.append(word[i]+word[i+1])
for i in range(len(a)):
if a[i][0] not in english or a[i][1] not in english:
continue
else:
b.append(a[i])
return b
def intersection(x, y):
x1 = x.copy()
y1 = y.copy()
a = []
for i in x1 :
if i in y1 :
a.append(i)
y1.remove(i)
return len(a)
def union(x,y):
x1 = x.copy() # 중복을 제거해주는 집합
x2 = x.copy() # 결과를 출력하는 집합
for i in y: # y에 있는 원소에 대하여
if i not in x1: # x에는 그 원소가 없다면
x2.append(i) # x2 에 i를 추가
else:
x1.remove(i)
return len(x2)
def solution(str1, str2):
# 입력된 문자열을 다중집합으로 변환
str1 = make_set(str1)
print(str1)
str2 = make_set(str2)
print(str2)
if str1 == [] and str2 == []: # 둘 다 공집합인 경우, J(A,B)를 1로 정의
return 1 * 65536
inte = intersection(str1, str2)
print(inte)
uni = union(str1, str2)
print(uni)
answer= math.floor((inte / uni) * 65536)
return answer
solution("E=M*C^2", "e=m*c^2")