Skip to content

Commit 9f63f9c

Browse files
committed
94차 1번 문제 풀이
1 parent bcbcb2c commit 9f63f9c

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

live9/test94/문제1/박희경.py

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

0 commit comments

Comments
 (0)