We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 7ae6f07 commit 4953290Copy full SHA for 4953290
1 file changed
βing-eoking/λ°©μ κ°μ.pyβ
@@ -0,0 +1,13 @@
1
+def solution(arrows):
2
+ dx = [0, 1, 1, 1, 0, -1, -1, -1]
3
+ dy = [1, 1, 0, -1, -1, -1, 0, 1]
4
+ vertex, edge = {(0, 0)}, set()
5
+ x, y = 0, 0
6
+ for arrow in arrows:
7
+ for _ in range(2):
8
+ nx, ny = x + dx[arrow], y + dy[arrow]
9
+ a, b = (x, y), (nx, ny)
10
+ edge.add(tuple(sorted([a, b])))
11
+ vertex.add((nx, ny))
12
+ x, y = nx, ny
13
+ return 1 - len(vertex) + len(edge)
0 commit comments