r/adventofcode • • Dec 09 '19

SOLUTION MEGATHREAD -🎄- 2019 Day 9 Solutions -🎄-

--- Day 9: Sensor Boost ---


Post your solution using /u/topaz2078's paste or other external repo.

  • Please do NOT post your full code (unless it is very short)

  • If you do, use old.reddit's four-spaces formatting, NOT new.reddit's triple backticks formatting.

(Full posting rules are HERE if you need a refresher).


Reminder: Top-level posts in Solution Megathreads are for solutions only. If you have questions, please post your own thread and make sure to flair it with Help.


Advent of Code's Poems for Programmers

Click here for full rules

Note: If you submit a poem, please add [POEM] somewhere nearby to make it easier for us moderators to ensure that we include your poem for voting consideration.

Day 8's winner #1 AND #2:

Okay, folks, /u/Aneurysm9 and I deadlocked between two badass submissions that are entirely too good and creative to choose between. When we asked /u/topaz2078's wife to be the tie-breaker, her literal words:

[23:44] <TopazWife> both
[23:44] <TopazWife> do both
[23:44] <TopazWife> holy hell

So we're going to have two winners today!

  1. "A Sonnet of Sojourning", a sonnet in frickin' iambic pentameter by /u/DFreiberg!

  2. "A Comedy of Syntax Errors", a code-"poem" by /u/MaxMonkeyMax!

Both of you, enjoy your Reddit Silver, and good luck with the rest of the Advent of Code!


This thread will be unlocked when there are a significant number of people on the leaderboard with gold stars for today's puzzle.

EDIT: Leaderboard capped, thread unlocked at 00:14:46!

30 Upvotes

315 comments sorted by

View all comments

3

u/Rick-T Dec 09 '19

HASKELL

I'm linking my Intcode library, because basically all the changes happened there. The puzzle-specific code for today is just "load the memory and run the program".

My Intcode computer was already pretty well equipped to handle today's problem. The few changes I had to make were the following:

  • Change all the Ints to Integers (to handle big numbers)

  • Change the Memory from a Sequence to a Map (to handle access outside the initial code's address space)

  • Add the relative base offset to the state

  • Add "Relative" to the parameter mode type

  • Add the new opcode to modify the offset

  • Add another ParameterMode parameter to all the actions that write to an address

  • Handle the Relative ParameterMode when reading the address to write to

Looks like a long list, but every change was pretty small itself and so I was done pretty quickly.

In the end I must say: I really enjoyed building the Intcode computer. I like the idea that you build something bigger than usual over multiple days. However, I'm also glad that it is finished now. Once you have a well-built computer, adding more instructions becomes more of a mundane task instead of a challenging puzzle. I really like the progression from day 2 to day 7, but compared to that I did enjoy day 9 a lot less.

→ More replies (2)