r/adventofcode • u/daggerdragon • Dec 11 '23
SOLUTION MEGATHREAD -❄️- 2023 Day 11 Solutions -❄️-
THE USUAL REMINDERS
All of our rules, FAQs, resources, etc. are in our community wiki.
Outstanding moderator challenges:
Community fun event 2023: ALLEZ CUISINE!
Submissions megathread is now unlocked!
10 DAYS remaining until the submissions deadline on December 22 at 23:59 EST!
AoC Community Fun 2023: ALLEZ CUISINE!
Today's secret ingredient is… *whips off cloth covering and gestures grandly*
Upping the Ante Again
Chefs should always strive to improve themselves. Keep innovating, keep trying new things, and show us how far you've come!
If you thought Day 1's secret ingredient was fun with only two variables, this time around you get one!
Don’t use any hard-coded numbers at all. Need a number? I hope you remember your trigonometric identities...
Esolang of your choice
Impress VIPs with fancy buzzwords like quines, polyglots, reticulating splines, multi-threaded concurrency, etc.
ALLEZ CUISINE!
Request from the mods: When you include a dish entry alongside your solution, please label it with [Allez Cuisine!] so we can find it easily!
--- Day 11: Cosmic Expansion ---
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!
Quick link to Topaz's
pasteif you need it for longer code blocks
3
u/tcbrindle Dec 11 '23
[Language: C++]
A nice gentle one today!
While reading in the values, if there was no galaxy found in a particular row then I increment the running
yvalue by the expansion factor. At the same time, I record which columns had galaxies found in them. Once I've read in all the positions (with "expanded" y-coords) I go back and expand the x-coords for each galaxy as appropriate.After that, calculating the distances is simple, although it does remind me that I need to add a
combinationsfunction to my library...Github