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

1

u/nirgle Dec 11 '18

Thanks for the good analysis. I hadn't heard of golden-section search before. I've re-done my Day 10 with it (in Haskell) instead of iterating through all the intervening states. Run time is down from ~4s to ~0.25s

https://github.com/jasonincanada/aoc-2018/blob/master/src/Day10.hs#L121

1

u/aphirst Dec 11 '18

You're welcome, and I'm glad you were able to learn something from what I wrote! Functional languages still remain a bit of a mystery to me, but you seem to have the idea given the huge improvement. Do you just start from t=0 or do you also attempt to estimate a "better" starting point like I do?

1

u/nirgle Dec 11 '18

I use 0-20,000 as the starting interval. I already knew from poking around the iteration space that the solution was a bit after 10,000 so I chose an interval that would put it about halfway through.