[Programmers | Level 2] 방문 길이 (Python)
dy, dx = [-1, 1, 0, 0], [0, 0, -1, 1] cmd = {'U': 0, 'D': 1, 'L': 2, 'R': 3} def solution(dirs): visited = [[[0] * 4 for _ in range(11)] for _ in range(11)] cur = [5, 5] ans = 0 for i in dirs: y = cur[0] x = cur[1] ny = y + dy[cmd[i]] nx = x + dx[cmd[i]] if ny = 11 or nx >= 11: continue cur = [ny, nx] if i == 'U': if visited[ny][nx][1] == 0: ans += 1 visited[y][x][0] = 1 vis..