r/adventofcode • • Dec 09 '18

SOLUTION MEGATHREAD -🎄- 2018 Day 9 Solutions -🎄-

--- Day 9: Marble Mania ---


Post your solution as a comment or, for longer solutions, consider linking to your repo (e.g. GitHub/gists/Pastebin/blag or whatever).

Note: The 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: The Party Game!

Click here for rules

Please prefix your card submission with something like [Card] to make scanning the megathread easier. THANK YOU!

Card prompt: Day 9

Transcript:

Studies show that AoC programmers write better code after being exposed to ___.


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:29:13!

22 Upvotes

283 comments sorted by

View all comments

Show parent comment

23

u/xthexder Dec 09 '18

For anyone that solved this using arrays, insertions/deletions are a very slow operation. Many people probably had to re-implement their solution for Part 2. Linked lists are definitely ideal for this problem.

9

u/VikeStep Dec 09 '18

Can confirm this is what affected me, I got #23 for part 1 but didn't make top 100 for part 2 since arrays were too slow and I thought we had to identify a pattern in the numbers or something, so I spent 20 minutes on that.

8

u/nuvan Dec 09 '18

Gee, that thought process sounds familiar...

2

u/throwaway_the_fourth Dec 09 '18

Yep! I didn't make it onto the leaderboard for either part because I missed details of the problem and struggled with silly things, but I solved part A with an array-list and had to rewrite a (much more elegant) linked-list for part B.