We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent bcbcb2c commit 9f63f9cCopy full SHA for 9f63f9c
1 file changed
live9/test94/문제1/박희경.py
@@ -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