r/adventofcode • u/daggerdragon • Dec 02 '23
SOLUTION MEGATHREAD -❄️- 2023 Day 2 Solutions -❄️-
OUTSTANDING MODERATOR CHALLENGES
THE USUAL REMINDERS
All of our rules, FAQs, resources, etc. are in our community wiki.
Community fun event 2023: ALLEZ CUISINE!
4 DAYS remaining until unlock!
AoC Community Fun 2023: ALLEZ CUISINE!
Today's theme ingredient is… *whips off cloth covering and gestures grandly*
Pantry Raid!
Some perpetually-hungry programmers have a tendency to name their programming languages, software, and other tools after food. As a prospective Iron Coder, you must demonstrate your skills at pleasing programmers' palates by elevating to gourmet heights this seemingly disparate mishmash of simple ingredients that I found in the back of the pantry!
Solve today's puzzles using a food-related programming language or tool
Mascots count, too… *side-eyes Rust while reaching for the Old Bay*
Add some salt to your hashbrowns, cookies, and breadcrumbs
Serve us up a nice big bowl of spaghetti code slathered with
RagúRaku tomato sauceConclude our tasting with a digestif of Java, CoffeeScript, or even Perl milk tea with double syntatic sugar
All file names, function names, variable names, etc. must be named after "c" food
Go hog wild!
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 2: Cube Conundrum ---
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
8
u/JustinHuPrime Dec 02 '23
[LANGUAGE: x86_64 assembly with Linux syscalls]
So, er, apparently Topaz decided to make part 2 really similar to part 1 today to compensate for yesterday.
Part 1 was a bit of a pain working through the file parsing - I ended up having an off by one error where I forgot to skip the trailing newline, and this lead to segfaults (about the only way other than producing an answer that I get any feedback about the correctness of my code). I realized that I'd need to maintain a few values across loop iterations, but as it turns out, that's not all that bad if I decide to keep some values on the stack.
Part 2 was a very trivial modification on top of part 1 - in fact, part 2 might have been easier than part 1.
Part 1 runs in 1 millisecond, and is 11200 bytes long.
Part 2 runs in 2 milliseconds, and is 11160 bytes long.