[Ch.5 - DFS/BFS] 미로 탈출
My code from collections import deque n,m = map(int,input().split()) miro = [] for i in range(n): miro.append(list(map(int,input().split()))) dx = [-1,1,0,0] dy = [0,0,-1,1] def bfs(x,y): queue = deque() queue.append((x,y)) while queue: x, y = queue.popleft() for i in range(4): nx = x + dx[i] ny = y + dy[i] if nx = n or ny = m: continue if miro[nx][ny] == 0: continue if miro[nx][ny] == 1: miro[n..
2022. 2. 11.
[Ch.4 - 구현] 게임 개발
My code n,m = map(int,input().split()) #map 의 세로와 가로 크기를 입력 받음 a,b,d = map(int,input().split()) #현재 캐릭터의 좌표값과 방향을 입력 받음 went = [[0]*m for i in range(n)] #방문했음을 표시하는 배열 만들어줌 went[a][b] = 1 #현재 캐릭터의 위치에 방문했음을 표시 array = [] for i in range(n): array.append(list(map(int,input().split()))) #map 의 육지,바다 값을 입력 받아 줌 da = [-1,0,1,0] #북,남을 나타내는 방향 변수 db = [0,1,0,-1] #동,서를 나타내는 방향 변수 def turn_left(): #왼쪽으로 ..
2022. 2. 9.
[Ch.4 - 구현] 왕실의 나이트
My code data = input() row = int(data[1]) column = int(ord(data[0])) - int(ord('a')) + 1 steps = [(1,2),(2,1),(-1,-2),(-2,-1),(-2,1),(2,-1),(1,-2),(-1,2)] result = 0 for step in steps: next_row = row + step[0] next_column = column + step[1] if next_row >= 1 and next_row = 1 and next_column = 1 and next_row = 1 and next_column
2022. 2. 5.