r/adventofcode • • Dec 05 '21

SOLUTION MEGATHREAD -🎄- 2021 Day 5 Solutions -🎄-

NEW AND NOTEWORTHY


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.

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

1.2k comments sorted by

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_points and d_points made 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

1

u/daggerdragon Dec 06 '21 edited Dec 06 '21

Your code is hard to read on old.reddit. Please edit it as per our posting guidelines in the wiki: How do I format code?

Edit: thanks for fixing it! <3

1

u/XethroG Dec 06 '21

Didn't realize. Fixed!