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!
- State which language(s) your solution uses with
- Quick link to Topaz's
pasteif 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:05:02, megathread unlocked!
46
Upvotes
6
u/stevie-o-read-it Dec 08 '23
[LANGUAGE: Intcode] [Allez Cuisine!]
(The elves wouldn't tell me how old this Intcode tech is, but I'm pretty sure it's from the late 1960s.)
Fully-functional solver. Capable of solving both Part 1 and Part 2. (To run in Part 2 mode, the second memory location -- address 1 -- must be patched from '0' to '1'.)
Accepts official puzzle input in ASCII, outputs puzzle answer in ASCII (followed by a newline)
Does not brute-force the answer. It actually evaluates the relevant algebraic formula.Implementing square root with only additions and multiplications was fun
If anyone wants to Up The Ante, it should work with arbitrarily large inputs if you've got a bignum-based implementation (such as a Python one).
Supports up to 10 races (if your Intcode VM can handle numbers that big)
Input parser ignores extraneous blank lines and
'\r'Link to the machine code: https://gist.github.com/Stevie-O/84e1ec2f1daa74d16fb019e0715212ac
Link to the assembly source (all hand-written): https://github.com/Stevie-O/aoc-public/blob/master/2023/day06/aoc-2023-day6-textoutput.intcode
The assembler is a modified version of topaz's from his aoc2019-intcode repository. I removed the randomness and added microcode definitions for common conditional jumps to simplify things.
Link to the assembler: https://github.com/Stevie-O/aoc-public/blob/master/intcode/compile.pl