53
SOLUTION MEGATHREAD-🎄- 2019 Day 3 Solutions -🎄-(self.adventofcode)
submitted 6 years, 1 month ago* (edited 14 minutes after) by daggerdragon to /r/adventofcode (134.8k)
6 years ago
—
6 years, 1 month ago7 of 7
Tip Reveddit Real-Time can notify you when your content is removed.
your account history
Tip Check if your account has any removed comments.
view my removed comments you are viewing a single comment's thread.
view all comments


Python
I still have a lot to work on in terms of the leaderboard (610 / 576), but I think my solutions were elegant. My code was super messy at first, but I always clean it up afterwards.
Part 1
Part 2
Very nice. The only thing I would change is moving the definition of
outside of the loop. Python might be smart enough not to redefine it every time though.
I tried, but it made the code longer and didn't change the time much, so I think it's no different than chained if statements.
I haven't used python in a long time, I am understanding other python solutions to this problem, but this one gives me a blip for some reason. maybe some syntax I need to review, Can you explain this a little. I know other people say it's clear, but not to me atm...
Going to write my own using a brute force solution but I want to know why this solution is better
I am thinking the definition for L,R,U,D is arbitrary as long as it's consistent?
Instead of
{"L": (0, -1), "R": (0, 1), "U": (1, 1), "D": (1, -1)}I would think it would be,
{"L": (-1, 0), "R": (1, 0), "U": (0, 1), "D": (0, -1)}The diagonal move for up and down and the inverted x and y for L and R is what is getting me, but I think I'm misunderstanding something simple about this
Those aren't deltas for the x and y access, they're incrementors. I should've made it more obvious, but the first number says whether the x or y axis is modified, while the second says by how much. So for L it's (0, -1), not (-1, 0), because x is modified (0) by -1 (to the left).
Awesome, thanks for the explanation
edit: obvious now lol, thanks again
this is great - so simple, clear, and readable.