LOADING: An error occurred. Update Chrome, try Firefox, or visit this post for more details.

⚠️Reddit changed how removals work, which breaks Reveddit's website. Install the extension to track removed content:Add to chromeAdd to firefoxWhat changed?
✖︎
about reveddit
⚙F.A.Q.add-ons
r/
status
copy sharelink
[+] show filters
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)
512 commentsredditother-discussionssubreddit-indexmessage modsop-focus

--- Day 3: Crossed Wires ---


Post your solution using /u/topaz2078's [paste](https://topaz....

... view full text

6 years ago
—
6 years, 1 month ago
7 of 7

Tip Reveddit Real-Time can notify you when your content is removed.

your account history
(check your username's removed content. why?)
Tip Check if your account has any removed comments.
view my removed comments
you are viewing a single comment's thread.
view all comments
[–][deleted]7 points6 years, 1 month ago

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

permalinkhide replies (3)as-of
[–]Dagur3 points6 years, 1 month ago

Very nice. The only thing I would change is moving the definition of

{"L": (0, -1), "R": (0, 1), "U": (1, 1), "D": (1, -1)} 

outside of the loop. Python might be smart enough not to redefine it every time though.

permalinkparentcontexthide replies (1)author-focusas-ofpreserve
[–][deleted]1 point6 years, 1 month ago

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.

permalinkparentcontextas-of
[–]ThiccChungus_922 points6 years ago

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

permalinkparentcontexthide replies (1)author-focusas-ofpreserve
[–][deleted]1 point6 years ago

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).

permalinkparentcontexthide replies (1)as-of
[–]ThiccChungus_922 points6 years ago* (edited 3 minutes after)

Awesome, thanks for the explanation

edit: obvious now lol, thanks again

permalinkparentcontextauthor-focusas-ofpreserve
[–][deleted]2 points6 years, 1 month ago

this is great - so simple, clear, and readable.

permalinkparentcontextas-of
r/revedditremoved.substack.com
🚨 NEWS 🚨
✖︎

Important: Reddit Changed How Removals Work

A recent Reddit update makes mod-removed content disappear from profile pages, which breaks Reveddit's website.

Install the browser extension to receive removal alerts.

Add to chromeAdd to firefox

What changed?

r/revedditremoved.substack.com