[프로그래머스] 달리기 경주
def solution(players, callings): # {'mumu': 0, 'soe': 1, 'poe': 2, 'kai': 3, 'mine': 4} player_dict = {player:rank for rank,player in enumerate(players)} # {0: 'mumu', 1: 'soe', 2: 'poe', 3: 'kai', 4: 'mine'} rank_dict = {rank:player for rank,player in enumerate(players)} for call in callings: call_index = player_dict[call] prev_index = call_index -1 player_dict[rank_dict[call_index]], player_di..
2023. 6. 23.
[백준 16236번] 아기 상어
from collections import deque n = int(input()) area = [] result = 0 shark_size = 2 ate_fish = 0 nx = [-1,1,0,0] ny = [0,0,-1,1] for i in range(n): area.append(list(map(int,input().split()))) for i in range(n): for j in range(n): if area[i][j] == 9: shark_location_x, shark_location_y = i, j def bfs(x,y,sharkSize): visited = [[False]*n for _ in range(n)] distence = [[0]*n for _ in range(n)] visite..
2023. 5. 27.
[HackerRank] Count Luck
def countLuck(matrix, k): row = len(matrix) col = len(matrix[0]) nx = [-1,1,0,0] ny = [0,0,-1,1] start_x, start_y = 0, 0 count = 0 graph = [] for i in range(row): graph.append(list(matrix[i])) for i in range(row): for j in range(col): if graph[i][j] == 'M': start_x, start_y = i, j # Write your code here def dfs(area, x, y): # visited[x][y] = True if area[x][y] == '*': return True direct_count = ..
2023. 5. 19.