나의 답안
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
'코딩 테스트 (Coding Test)' 카테고리의 다른 글
[프로그래머스] 귤 고르기 - 파이썬 풀이 (0) | 2023.01.18 |
---|---|
[프로그래머스] 전화번호 목록 - 파이썬 풀이 (0) | 2023.01.18 |
[프로그래머스] n^2 배열 자르기 (0) | 2023.01.18 |
[프로그래머스] 2019 카카오 겨울 인턴 - 튜플 - 파이썬 풀이 (0) | 2023.01.18 |
[프로그래머스] 위장 - 파이썬 풀이 (0) | 2023.01.18 |