문제 링크

풀이 과정

전체 코드

def all_alpha(sub_str):
    return sub_str[0].isalpha() and sub_str[1].isalpha()

def make_set(full_str):
    target_set = set()
    char_dict = dict()
    
    for i in range(len(full_str)-1):
        sub_str = full_str[i:i+2]
        if all_alpha(sub_str):
            if sub_str in char_dict:    char_dict[sub_str] += 1
            else:   char_dict[sub_str] = 0
            target_set.add(sub_str + '_' + str(char_dict.get(sub_str)))
            
    return target_set

def solution(str1, str2):
    answer = 0
    str1, str2 = str1.lower(), str2.lower()
    set1 = make_set(str1)
    set2 = make_set(str2)  
    union_len = len(set1.union(set2))
    inter_len = len(set1.intersection(set2))
    
    if union_len == 0 and inter_len == 0:   return 65536
    elif union_len != 0 and inter_len == 0:  return 0
    elif union_len != 0 and inter_len != 0:    
        return int(inter_len / union_len * 65536)