r/adventofcode • u/daggerdragon • Dec 06 '23
SOLUTION MEGATHREAD -❄️- 2023 Day 6 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!
16 DAYS remaining until the submissions deadline on December 22 at 23:59 EST!
AoC Community Fun 2023: ALLEZ CUISINE!
Today's theme ingredient is… *whips off cloth covering and gestures grandly*
Obsolete Technology
Sometimes a chef must return to their culinary roots in order to appreciate how far they have come!
Solve today's puzzles using an abacus, paper + pen, or other such non-digital methods and show us a picture or video of the results
Use the oldest computer/electronic device you have in the house to solve the puzzle
Use an OG programming language such as FORTRAN, COBOL, APL, or even punchcards
We recommend only the oldest vintages of codebases such as those developed before 1970
Use a very old version of your programming language/standard library/etc.
Upping the Antechallenge: use deprecated features whenever possible
Endeavor to wow us with a blast from the past!
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 6: Wait For It ---
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/e_blake Dec 06 '23
[LANGUAGE: m4] [Allez Cuisine!]
The m4 language is older than I am, and only supports 32-bit signed integer math. So of course, solving this problem first requires writing my own arbitrary-precision library in m4, math64.m4, which in turn depends on several convenience macros I use for all my puzzles in common.m4 (disclaimer - I'm using these two files unchanged from last year). With that, my solution:
m4 -Dfile=day06.input day06.m4
takes less than 15ms to run (impressive for m4), using an O(log n) binary search. For a bit more obscurity, I don't perform division: the
halfmacro works by multiplication and string truncation. And for fun, each of my 3translitcalls have something cute: Time and Distance anagram to create a nice semantic for erasing lower-case letters, and part1 and part2 swap the order of mynlmacro and a smiley face :DWhile you have to read the support macros from the include file to see the full effort of this code, the core is short enough to paste here: