본문 바로가기
PROGRAMMERS 43162: 네트워크 Link : programmers.co.kr/learn/courses/30/lessons/43162 Python 더보기 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 def DFS(node, network, link_data, value): for i in link_data[node]: if i in network: if network[i] == -1: network[i] = value DFS(i, network, link_data, value) def solution(n, computers): global map_size map_size = n node_data = d.. 2021. 1. 6.
PROGRAMMERS 42860: 조이스틱 Link : programmers.co.kr/learn/courses/30/lessons/42860 Python 더보기 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 alphabet = [str(chr(i + 65)) for i in range(26)] def small_distance(word): # 문자의 최소 길이 pos = alphabet.index(word) d1 = 0 for i in range(26): if alphabet[(pos + i) % 26] == 'A': d1 = i break .. 2021. 1. 6.
PROGRAMMERS 43238: 입국 심사 Link : programmers.co.kr/learn/courses/30/lessons/43238 Python 더보기 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 def solution(n, times): times.sort() max_value = n * times[-1] s = 0 e = max_value find_min = 1000000000 * 1000000000 # 찾은 수 while s 2021. 1. 5.
PROGRAMMERS 43165: 타겟 넘버 Link : programmers.co.kr/learn/courses/30/lessons/43165 Python 더보기 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 counter = 0 def DFS(numbers, target, deapth, length): global counter if deapth == length: if sum(numbers) == target: counter += 1 else: numbers[deapth] *= -1 DFS(numbers, target, deapth + 1, length) numbers[deapth] *= -1 DFS(numbers, target, deapth + 1, length) def solution(numbers, ta.. 2021. 1. 5.
PROGRAMMERS 42885: 구명보트 Link : programmers.co.kr/learn/courses/30/lessons/42885 Python 더보기 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 def solution(people, limit): people.sort(reverse=True) counter = 0 s_tp = 0 e_tp = len(people) - 1 while e_tp - s_tp >= 0: if people[s_tp] + people[e_tp] 2021. 1. 5.