728x90

카카오 문제를 오랜만에 맞췄다. 거의 다 풀고 for 문 범위 하나 때문에 시간이 걸렸다.

def solution(str1, str2):
    answer = 0
 
    str1 = str1.lower()
    str2 = str2.lower()
 
    a = [ ]
    b = [ ]
 
    for i in range(0,len(list(str1))-1):
        if str1[i:i+2].isalpha() == True:
            a.append(str1[i:i+2])
 
    for i in range(0,len(list(str2))-1):
        if str2[i:i+2].isalpha() == True:
            b.append(str2[i:i+2])
 
    kyo = 0
 
 
    if len(a)==0 and len(b)==0:
        return  65536
 
    b_copy = b.copy()
 
    check = [ ]
    for i in range(0,len(a)):
        if a[i] in b_copy and a[i] not in check:
 
            kyo += min(a.count(a[i]),b.count(a[i]))
            check.append(a[i])
 
 
 
 
    l = len(a)+len(b)-kyo
    return int(kyo/l*65536)
728x90

+ Recent posts