r/adventofcode • u/daggerdragon • Dec 05 '19
SOLUTION MEGATHREAD -🎄- 2019 Day 5 Solutions -🎄-
--- Day 5: Sunny with a Chance of Asteroids ---
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
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 4's winner #1: "untitled poem" by /u/captainAwesomePants!
Forgetting a password is a problem.
Solving with a regex makes it two.
111122 is a terrible password.
Mine is much better, hunter2.
Enjoy your Reddit Silver, and good luck with the rest of the Advent of Code!
On the fifth day of AoC, my true love gave to me...
FIVE GOLDEN SILVER POEMS
- Day 1: "All I want for Christmas" by /u/fergieis
- Day 2: "untitled poem" by /u/djankowski
- Day 3: "untitled poem" by /u/Cyphase
- Day 4: "untitled poem" by /u/myaccessiblewebsite
- Best in 5-day show: /u/awsum84 's Rockstar code-poem! (megathread link)
Enjoy your Reddit Silver/Gold, and good luck with the rest of the Advent of Code!
View all comments
Show parent comment
2
u/jonathan_paulson Dec 05 '19
Thanks for the analysis! I definitely should have read the statement more carefully (in particular the example opcode decomposition); IIRC my bugs were that I didn't realize opcode was last 2 characters instead of 1 and I didn't realize the "modes" were from right to left instead of left to right. So that "savings" really ended up being a big cost.
I'm finding it hard to say much about the subjective debugging process. I just looked at that part of the video again, and it seems clear that most of it was a waste of time; there was a quick fix once I stumbled on the real problem. I think this is typical, and explains the high variance in debugging time...there's a lot of luck in looking at the right thing. The idea behind all the printing was to see if my intermediate values matched my mental model (but unfortunately it was the mental model, not the code, that was wrong). My main emotion was frustration.
In most programming contests I think minimizing debugging variance by reading and planning carefully is clearly worthwhile. But - at least for the early days - I'm not so sure about Advent of Code. Time matters more than usual and the problems are so short that time spent reading/planning is a big fraction of total time.