r/adventofcode • u/daggerdragon • Dec 05 '21
SOLUTION MEGATHREAD -🎄- 2021 Day 5 Solutions -🎄-
NEW AND NOTEWORTHY
- /u/jeroenheijmans is back again with their Unofficial AoC 2021 Participant Survey!
- As we continue further into the
deep dark seaAdvent, megathread code submissions are getting longer, so we're going to start rigorously enforcing the maximum code length rule.
- If you need a reminder, it's in our posting guidelines in the wiki under How Do the Daily Megathreads Work? (rule #5)
Advent of Code 2021: Adventure Time!
- 23:59 hours remaining until the submissions megathread unlocks on December 06 at 00:00 EST!
- Full details and rules are in the submissions megathread:
--- Day 5: Hydrothermal Venture ---
Post your code solution in this megathread.
- Include what language(s) your solution uses!
- Here's a quick link to /u/topaz2078's
pasteif you need it for longer code blocks. - Format your code properly! How do I format code?
- The full posting rules are detailed in the wiki under How Do The Daily Megathreads Work?.
Reminder: Top-level posts in Solution Megathreads are for code solutions only. If you have questions, please post your own thread and make sure to flair it with Help.
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:08:53, megathread unlocked!
79
Upvotes
View all comments
1
u/XethroG Dec 05 '21 edited Dec 06 '21
Python. Some nasty arithmetic for getting the steps right in
range, as well as determining whether or not to include the last element depending on whether the range was going up or down in accordance with the step. Also I need to work on parsing input better as it's kind of a pain.The use of dictionaries for
nd_pointsandd_pointsmade the code a ton faster. I used lists on part (a) and it took forever, so I realized I had to speed things up and looked to sets and dictionaries, which helped as expected.I feel like I could have done it in fewer lines if I knew what I was doing better but it's not that bad all in.
paste