From c201d2f50af78f95a5d9c5cd77528ebf820ef2cb Mon Sep 17 00:00:00 2001 From: Jisan <149364697+kjs254@users.noreply.github.com> Date: Sun, 10 Mar 2024 22:05:42 +0900 Subject: [PATCH] =?UTF-8?q?2024-03-10=20=EB=89=B4=EC=8A=A4=20=ED=81=B4?= =?UTF-8?q?=EB=9F=AC=EC=8A=A4=ED=84=B0=EB=A7=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kjs254/README.md | 3 +- ...54\354\212\244\355\204\260\353\247\201.py" | 39 +++++++++++++++++++ 2 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 "kjs254/\352\265\254\355\230\204/\353\211\264\354\212\244 \355\201\264\353\237\254\354\212\244\355\204\260\353\247\201.py" diff --git a/kjs254/README.md b/kjs254/README.md index 1dbef24..2ad36a5 100644 --- a/kjs254/README.md +++ b/kjs254/README.md @@ -9,5 +9,6 @@ | 5차시 | 2024.02.24 | DFS | [모음사전](https://school.programmers.co.kr/learn/courses/30/lessons/84512) | [#19](https://github.com/AlgoLeadMe/AlgoLeadMe-7/pull/19) | | 6차시 | 2024.02.27 | 스택 | [괄호 회전하기](https://school.programmers.co.kr/learn/courses/30/lessons/76502) | [#22](https://github.com/AlgoLeadMe/AlgoLeadMe-7/pull/22) | | 7차시 | 2024.03.01 | 구현 | [캐시](https://school.programmers.co.kr/learn/courses/30/lessons/17680) | [#24](https://github.com/AlgoLeadMe/AlgoLeadMe-7/pull/24) | -======= +| 8차시 | 2024.03.08 | 구현 | [튜플](https://school.programmers.co.kr/learn/courses/30/lessons/64065) | [#30](https://github.com/AlgoLeadMe/AlgoLeadMe-7/pull/30) | +| 9차시 | 2024.03.08 | 구현 | [뉴스 클러스터링](https://school.programmers.co.kr/learn/courses/30/lessons/17677) | [#33](https://github.com/AlgoLeadMe/AlgoLeadMe-7/pull/33) | --- \ No newline at end of file diff --git "a/kjs254/\352\265\254\355\230\204/\353\211\264\354\212\244 \355\201\264\353\237\254\354\212\244\355\204\260\353\247\201.py" "b/kjs254/\352\265\254\355\230\204/\353\211\264\354\212\244 \355\201\264\353\237\254\354\212\244\355\204\260\353\247\201.py" new file mode 100644 index 0000000..c86c242 --- /dev/null +++ "b/kjs254/\352\265\254\355\230\204/\353\211\264\354\212\244 \355\201\264\353\237\254\354\212\244\355\204\260\353\247\201.py" @@ -0,0 +1,39 @@ +def MakeSet(s): #2글자씩 끊은 알파벳만 리스트로 출력 + lst = [] + for i,_ in enumerate(s[:-1]): + a = s[i:i+2] + if a.isalpha(): + lst.append(a.lower()) + return lst + +def func(l1, l2): #중복 교집합과 중복 합집합의 길이를 각각 출력 + intersection_set, union_set = [], [] + inter = set(l1) & set(l2) + union = set(l1) | set(l2) + + for n in union: + intersection_num = min(l1.count(n),l2.count(n)) + union_num = max(l1.count(n),l2.count(n)) + + for _ in range(intersection_num): + intersection_set.append(n) + + for _ in range(union_num): + union_set.append(n) + + return len(intersection_set), len(union_set) + +def solution(str1, str2): #메인 코드 + answer = 0 + + arr1 = MakeSet(str1) + arr2 = MakeSet(str2) + + a,b = func(arr1,arr2) + + if b: + answer = int((a/b)*65536) + else: + answer = 65536 + + return answer \ No newline at end of file