본문 바로가기

Python/이것이 취업을 위한 코딩 테스트다(with 파이썬)25

이것이 취업을 위한 코딩테스트다 - 위에서 아래로 # 위에서 아래로 N = int(input()) S = [] for i in range(N): S.append(int(input())) S = sorted(S, reverse=True) for i in S: print(i, end=' ') 2022. 7. 3.
DFS,BFS - 미로 탈출 import collections from collections import deque import queue n, m = map(int, input().split()) graph = [] for i in range(n): graph.append(list(map(int, input()))) 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 graph.. 2022. 6. 26.
DFS,BFS - 음료수 얼려먹기 n, m = map(int, input().split()) a = [] for i in range(n): a.append(list(map(int, input()))) def dfs(x, y): if x = n or y = m: # 범위 지정 넘어가면 return False # False 반환 if a[x][y] == 0: a[x][y] = 1 dfs(x-1, y) dfs(x, y-1) dfs(x+1, y) dfs(x, y+1) return True return False result = 0 for i in range(n): for j in range(m): if dfs(i, j) == True: result += 1 print(result) 2022. 6. 26.
구현 - 게임 개발 # 게임개발 n, m = map(int, input().split()) d = [[0] * m for _ in range(n)] x, y, direction = map(int, input().split()) d[x][y] = 1 array = [] for i in range(n): array.append(list(map(int, input().split()))) dx = [-1, 0, 1, 0] dy = [0, 1, 0, -1] def turn_left(): global direction direction -= 1 if direction == -1: direction = 3 count = 1 turn_time = 0 while True: turn_left() nx = x + dx[direction] ny.. 2022. 6. 26.