목록위클리 챌린지 (3)
컴공생의 다이어리

[프로그래머스] 폰켓몬 - 파이썬(Python) def solution(nums): return min(len(nums) // 2, len(set(nums))) https://programmers.co.kr/learn/courses/30/lessons/1845 코딩테스트 연습 - 폰켓몬 당신은 폰켓몬을 잡기 위한 오랜 여행 끝에, 홍 박사님의 연구실에 도착했습니다. 홍 박사님은 당신에게 자신의 연구실에 있는 총 N 마리의 폰켓몬 중에서 N/2마리를 가져가도 좋다고 했습니다. programmers.co.kr

[프로그래머스] 전력망을 둘로 나누기 - 파이썬(Python) from collections import defaultdict, deque def bfs_and_node_count(del_line, n, wire_dict): # bfs 수행과 연결된 노드수 구하기 count = 1 # 연결된 노드 수 visited = [False] * (n + 1) # 방문여부 체크 visited[del_line[0]] = True # 시작 노드 방문 처리 queue = deque([del_line[0]]) while queue: # bfs 수행 curr = queue.popleft() for i in wire_dict[curr]: # curr 노드와 연결된 노드에 대해서 if visited[i] or i == del_..

[프로그래머스] 피로도 - 파이썬(Python) from itertools import permutations def solution(k, dungeons): answer = 0 len_dungeons = len(dungeons) for permu in permutations(dungeons, len_dungeons): # 순열로 경우를 만들어줌 temp_k = k # k는 그대로 보존하기 위해 temp_k를 k로 초기화 하고 사용 count = 0 # 던전 수 for p in permu: if temp_k >= p[0]: # 최소 필요 피로도가 있는지 확인 temp_k -= p[1] # 소모 피로도 빼주기 count += 1 # 던전 수 업데이트 answer = max(answer, count) # 최..