나의 답안

def task(str):
    tmp = []
    for i in range(len(str) - 1):
        if str[i].isalpha() and str[i + 1].isalpha():
            tmp.append(str[i] + str[i + 1])
    return tmp

def solution(str1, str2):
    str1 = str1.upper()
    str2 = str2.upper()
    a, b = task(str1), task(str2)
    c = set(a) & set(b)
    c2 = 0
    for i in c:
        c2 += min(a.count(i), b.count(i))

    d = set(a) | set(b)
    d2 = 0
    for i in d:
        d2 += max(a.count(i), b.count(i))

    if any(d):
        return int((c2 / d2) * 65536)
    else:
        return 65536

+ Recent posts