r/adventofcode • u/daggerdragon • Dec 13 '18
SOLUTION MEGATHREAD -🎄- 2018 Day 13 Solutions -🎄-
--- Day 13: Mine Cart Madness ---
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!
Please prefix your card submission with something like [Card] to make scanning the megathread easier. THANK YOU!
Card prompt: Day 13
Transcript:
Elven chronomancy: for when you absolutely, positively have 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:44:25!
24
Upvotes
View all comments
1
u/marmalade_marauder Dec 13 '18
Python, 47/60.
I realized my solution for part1 was actually incorrect but still worked because the cart initiating the crash moved before the cart being hit. I had to fix part2 to account for this. Basically if the cart1 moved into a position where a cart2 would then hit it, I missed this because I was still referencing the original position of cart1, not the updated. However I fixed that to account for both by taking the union of (unmoved carts) and (moved carts) to determine if a collision occurred.
Here is the... explicit? code. A lot of code, nothing really that fancy.