Skip to content

Instantly share code, notes, and snippets.

@vjeranc
Created December 18, 2023 10:03
Show Gist options
  • Save vjeranc/f6bf9d53595d45ba9e0bbb4e93563d50 to your computer and use it in GitHub Desktop.
Save vjeranc/f6bf9d53595d45ba9e0bbb4e93563d50 to your computer and use it in GitHub Desktop.
x, y, A, L, P2 = 0, 0, 0, 0, True
for d, s, c in map(str.split, open(0)):
s = int(c[2:-2], 16) if P2 else int(s)
if P2: d = "RDLU"[int(c[-2])]
nx, ny = x, y
if d=='R':
ny += s
elif d=='L':
ny -= s
elif d=='U':
nx -= s
elif d=='D':
nx += s
A += nx*y-x*ny
L += s
x, y = nx, ny
print(L+A//2-L//2+1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment