파이썬56 [PCCP 기출문제] 3번 > 충돌위험 찾기 - Python, Counter https://school.programmers.co.kr/learn/courses/30/lessons/340211 프로그래머스SW개발자를 위한 평가, 교육, 채용까지 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프programmers.co.kr 코드 & 풀이 from collections import Counterdef solution(points, routes): # 출발지부터 도착지까지 검사해야 됨 # 출발지에서 검사 한 번 하고 시작 or 공회전 한 번 돌리고 시작 new_routes = [] for route in routes: step = 0 x, y = points[route[0] - 1] tmp_route = .. 2025. 2. 27. 억억단을 외우자 - Python https://school.programmers.co.kr/learn/courses/30/lessons/138475 프로그래머스SW개발자를 위한 평가, 교육, 채용까지 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프programmers.co.kr 코드 & 풀이 def solution(e, starts): num_count = [0] * (e + 1) for i in range(1, int(e ** 0.5) + 1): for j in range(i, e // i + 1): num = i * j if i == j: num_count[num] += 1 else: .. 2025. 2. 21. 부대복귀 - Python, BFS https://school.programmers.co.kr/learn/courses/30/lessons/132266 프로그래머스SW개발자를 위한 평가, 교육, 채용까지 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프programmers.co.kr 코드 & 풀이 from collections import dequedef solution(n, roads, sources, destination): graph = [[] for _ in range(n + 1)] for start, end in roads: graph[start].append(end) graph[end].append(start) distances = [-1] * (n + 1) .. 2025. 2. 17. 2025 프로그래머스 코드챌린지 2차 예선 > 서버 증설 횟수 - Python, 구현 https://school.programmers.co.kr/learn/courses/30/lessons/389479 프로그래머스SW개발자를 위한 평가, 교육, 채용까지 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프programmers.co.kr 코드 & 풀이 def solution(players, m, k): answer = 0 size = len(players) servers = [0] * size def server_expansion(need_server, start): for idx in range(k): if start + idx = m: need_server = (player // m) - s.. 2025. 2. 15. 2025 프로그래머스 코드챌린지 1차 예선 > 비밀 코드 해독 - Python, Combinations, & 연산 https://school.programmers.co.kr/learn/courses/30/lessons/388352#qna 프로그래머스SW개발자를 위한 평가, 교육, 채용까지 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프programmers.co.kr 코드 & 풀이 from itertools import combinationsdef solution(n, q, ans): possible_code = list(combinations(range(1, n + 1), 5)) total_cnt = 0 for code in possible_code: make_code = True for i in range(len(q)): if.. 2025. 2. 14. 다익스트라(Dijkstra) - Python, heapq 코드import heapqimport sysdef dijkstra(graph, start): INF = float('inf') n = len(graph) distance = [INF] * n distance[start] = 0 pq = [] heapq.heappush(pq, (0, start)) # (거리, 정점) while pq: dist, now = heapq.heappop(pq) if distance[now] 과정 거리 배열 초기화: 시작 정점에서 모든 정점까지의 최단 거리를 무한(∞)으로 설정, 시작 정점의 거리는 0으로 설정우선순위 큐(Priority Queue) 사용: 시작 정점을 큐에 넣음 (우선순위 큐는 Python.. 2025. 2. 7. 이전 1 2 3 4 ··· 10 다음