뉴스 클러스터링
프로그래머스
코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.
programmers.co.kr
- 내 풀이
def solution(str1, str2):
answer=0
str1=str1.upper()
str2=str2.upper()
x=""
a=[]
b=[]
n,m=0,0
for i in range(len(str1)-1):
x=str1[i:i+2]
if x.isalpha(): #알파벳일 경우만
a.append(x)
for i in range(len(str2)-1):
x=str2[i:i+2]
if x.isalpha():
b.append(x)
ls=list(set(a+b))
for l in ls:
if l not in a and l not in b:
continue
elif l in a and l in b:
n+=min(a.count(l), b.count(l))
m+=max(a.count(l), b.count(l))
if m==0:
return 65536
return int((n/m)*65536)
str1, str2= "FRANCE", "french"
str1, str2= "handshake", "shake hands"
str1, str2= "aa1+aa2", "AAAA12"
str1, str2= "E=M*C^2", "e=m*c^2"
#결과
16384
65536
43690
65536
'코딩테스트 > 프로그래머스' 카테고리의 다른 글
| [프로그래머스] [Level 3] [Heap] 디스크 컨트롤러 (0) | 2022.10.23 |
|---|---|
| [프로그래머스] [Level 3] [해시] 베스트 앨범 (0) | 2022.10.06 |
| [프로그래머스] [Level 2] n^2 배열 자르기 (0) | 2022.09.22 |
| [프로그래머스] [Level 2] [2018 KAKAO BLIND RECRUITMENT] [캐시] 1차 캐시 (0) | 2022.09.12 |
| [프로그래머스] [Level 2] 이진 변환 반복하기 (0) | 2022.09.12 |