Skip to content

Commit 9e4d9f0

Browse files
author
hangyeol
committed
94차 1번 문제풀이
1 parent bcbcb2c commit 9e4d9f0

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

live9/test94/문제1/백한결.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
def solution(dirs):
2+
visited = set()
3+
current = (0, 0)
4+
5+
move = {'U': (0, 1), 'D': (0, -1), 'R': (1, 0), 'L': (-1, 0)}
6+
7+
for dir in dirs:
8+
x = current[0] + move[dir][0]
9+
y = current[1] + move[dir][1]
10+
11+
if -5 <= x <= 5 and -5 <= y <= 5:
12+
visited.add(tuple(sorted([current, (x, y)])))
13+
print(visited)
14+
current = (x, y)
15+
16+
count = len(visited)
17+
18+
return count

0 commit comments

Comments
 (0)