Created
December 18, 2023 10:03
-
-
Save vjeranc/f6bf9d53595d45ba9e0bbb4e93563d50 to your computer and use it in GitHub Desktop.
https://adventofcode.com/2023/leaderboard/day/18 finally top 100
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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