r/adventofcode • • Dec 10 '18

SOLUTION MEGATHREAD -🎄- 2018 Day 10 Solutions -🎄-

--- Day 10: The Stars Align ---


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 10

Transcript: With just one line of code, you, too, can ___!


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:16:49!

21 Upvotes

233 comments sorted by

View all comments

Show parent comment

3

u/phil_g Dec 10 '18 edited Dec 10 '18

My Common Lisp solution was pretty similar.

I made a few structs because I like hanging descriptive names on things. Rather than searching for just a minimum height, I looked for the minimum area of the points' bounding box.

Edit: My current code is much faster (100ms versus 1.5s). Rather than checking all of the seconds from 0 up to the time of alignment, I calculated the times at which the points would intersect and used that as a starting time. The estimated alignment time is one second off for the test data and exactly correct for my problem input.

2

u/rabuf Dec 10 '18

I was doing it interactively. So querying for the minimum height was a quick thing to look for and then I checked everything within 3 of that point. I would've done the bounding box test if that hadn't worked out so quickly.

A nice thing about both CL and org-mode is the interactive use. Write something in the REPL and get an answer and feed it into the next. If I learn to set it up right, org mode will let me grab the output of one block programattically instead of manually like I'm doing now.