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
77
SOLUTION MEGATHREAD-🎄- 2022 Day 11 Solutions -🎄-(self.adventofcode)
submitted 3 years, 1 month ago* (edited 17 minutes after) by daggerdragon to /r/adventofcode (134.8k)
1036 commentsredditother-discussionssubreddit-indexmessage modsop-focus

WIKI NEWS

  • The FAQ section of the wiki on [Code Formatting](https://www.reddit.com/r/adventofco...

... view full text

since 3 years, 1 month ago
6 of 6

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]3 points3 years, 1 month ago

python code on github

This took way too long for me due to me running into several pitfalls.

After my worry skyrocketed, my solution for part 2 tried to mine bitcoins apparently.

Also ran into problems due to not having made a deep copy of my initial monkey lists.

At that point I couldn't be bothered anymore and just did the init twice.

I'll take the 34 sloc though and I'm mostly happy with how I parsed the input - other than me giving up trying to wrangle a list of strings into a list of integers. It should have been easy on paper.

permalinkhide replies (1)as-of
[–]Psychological_War8012 points3 years, 1 month ago

How is this so short???

permalinkparentcontexthide replies (2)author-focusas-ofpreserve
[–][deleted]2 points3 years, 1 month ago* (edited 10 hours after)

I think the biggest code-savers I used in this one were:

Ditching my Java-programmer urges to make a class and instead working with lists and parsing the file by category rather than by monkey using list comprehension. List comprehension is starting to become my best friend since I've learned about it's existence on day 7.

"exec" to execute part of the instructions directly from input rather than trying to parse it myself. Though I'm fairly sure it could have been done shorter without having to pass globals and locals - or maybe even use eval instead of exec altogether. Eval has a return value whereas exec doesn't. Found both exec and eval today by google-fu - I thought if it's a script language that can be ran interactively from shell, it might as well be able to run stuff from a string. Turned out that was indeed the case.

permalinkparentcontexthide replies (1)as-of
[–]daggerdragon1 point3 years, 1 month ago* (edited 15 hours, 44 minutes after)

Comment removed due to naughty language (the entire first line). Keep the megathreads SFW.

If you edit your comment to take out the naughty language, I'll re-approve the comment.

Edit: I have taken the coal out of your stocking.

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

my bad. edited.

permalinkparentcontextas-of
[–]Psychological_War8012 points3 years, 1 month ago

ok wow this certainly helps! :

exec(m[1],globals(),loc)

I didn't know that was a thing. Neat! I never would have had a use for it until now, but it's neat that it exists.

Explanation: Exec evaluates code from string in first arg with other args as context

permalinkparentcontextauthor-focusas-ofpreserve
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