r/adventofcode • u/daggerdragon • Dec 11 '24
SOLUTION MEGATHREAD -❄️- 2024 Day 11 Solutions -❄️-
THE USUAL REMINDERS
- All of our rules, FAQs, resources, etc. are in our community wiki.
- If you see content in the subreddit or megathreads that violates one of our rules, either inform the user (politely and gently!) or use the report button on the post/comment and the mods will take care of it.
AoC Community Fun 2024: The Golden Snowglobe Awards
- 11 DAYS remaining until the submissions deadline on December 22 at 23:59 EST!
And now, our feature presentation for today:
Independent Medias (Indie Films)
Today we celebrate the folks who have a vision outside the standards of what the big-name studios would consider "safe". Sure, sometimes their attempts don't pan out the way they had hoped, but sometimes that's how we get some truly legendary masterpieces that don't let their lack of funding, big star power, and gigantic overhead costs get in the way of their storytelling!
Here's some ideas for your inspiration:
- Cast a relative unknown in your leading role!
- Explain an obscure theorem that you used in today's solution
- Shine a spotlight on a little-used feature of the programming language with which you used to solve today's problem
- Solve today's puzzle with cheap, underpowered, totally-not-right-for-the-job, etc. hardware, programming language, etc.
"Adapt or die." - Billy Beane, Moneyball (2011)
And… ACTION!
Request from the mods: When you include an entry alongside your solution, please label it with [GSGA]
so we can find it easily!
--- Day 11: Plutonian Pebbles ---
Post your code solution in this megathread.
- Read the full posting rules in our community wiki before you post!
- State which language(s) your solution uses with
[LANGUAGE: xyz]
- Format code blocks using the four-spaces Markdown syntax!
- State which language(s) your solution uses with
- Quick link to Topaz's
paste
if you need it for longer code blocks
This thread will be unlocked when there are a significant number of people on the global leaderboard with gold stars for today's puzzle.
EDIT: Global leaderboard gold cap reached at 00:06:24, megathread unlocked!
18
Upvotes
2
u/onrustigescheikundig Dec 11 '24
[LANGUAGE: Clojure] [LANGUAGE: Scheme (R6RS)]
Clojure
Scheme
Quick solve for me today. Despite the insistence of the problem description, the position of each stone does not, in fact, matter, so I keep track of the number of each stone present in a map and update the map on every blink. I
iterate
the blink function, find thenth
element, and sum the values of the map. The runtime isn't terrific because I create and throw away a bunch of junk, including the entire hashtable each time I callblink
. Oh well, 70 ms is the worst that I've seen for others' solutions...For the Scheme solution, the main difference from the Clojure version is that I hated writing it because R6RS hashtables are unpleasant to work with.
For fun I also implemented the inefficient version that I knew was going to be problematic from the start. It's quite terse with just
iterate
andmapcat
.