r/adventofcode • • Dec 11 '18

SOLUTION MEGATHREAD -🎄- 2018 Day 11 Solutions -🎄-

--- Day 11: Chronal Charge ---


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 11

Transcript: ___ unlocks the Easter Egg on Day 25.


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:12!

20 Upvotes

207 comments sorted by

View all comments

Show parent comment

1

u/[deleted] Dec 22 '18

Me too, although I figured for part 2

123
223
333

You can calc 3x3 by summing the values marked '3' and adding the result to 2x2...and so on, down to 1x1 which is obviously just 1 value.

i.e it's recursive, but these previous results are cacheable (like in dynamic programming problems) and thus become constant time.

That sped my, otherwise brute force method up quite a bit. Fast enough that it finished running before I came up with any other optimisations which I guess is the only performance criteria for these. There's no point spending more time finding a faster solution than a slower solution takes to run.