[ 프로그래머스 ] 성격 유형 검사하기
풀이 소요 시간 18분 생각보다 깔끔하게 풀렸다. def solution(survey, choices): answer = '' dict = {'R': 0, 'T': 0, 'C': 0, 'F': 0, 'J': 0, 'M': 0, 'A': 0, 'N': 0} for char, choi in zip(survey, choices): a, b = char[0], char[1] if choi 4: dict[b] += (choi - 4) for i in range(4): a = list(dict.items())[2*i] b = list(dict.items())[2*i+1] if a[1] ..
[ 프로그래머스 ] 게임 맵 최단거리
from collections import deque dx = [-1, 1, 0, 0] dy = [0, 0, -1, 1] def bfs(a, b, visited, maps, n, m): global dx, dy q = deque([(a, b)]) visited[a][b] = 1 while q: x, y = q.popleft() for i in range(4): nx = x + dx[i] ny = y + dy[i] if 0