r/adventofcode • u/daggerdragon • Dec 17 '19
SOLUTION MEGATHREAD -🎄- 2019 Day 17 Solutions -🎄-
--- Day 17: Set and Forget ---
Post your full code solution using /u/topaz2078's paste or other external repo.
- Please do NOT post your full code (unless it is very short)
- If you do, use old.reddit's four-spaces formatting, NOT new.reddit's triple backticks formatting.
(Full posting rules are HERE if you need a refresher).
Reminder: Top-level posts in 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's Poems for Programmers
Note: If you submit a poem, please add [POEM] somewhere nearby to make it easier for us moderators to ensure that we include your poem for voting consideration.
Day 16's winner #1: "O FFT" by /u/ExtremeBreakfast5!
long poem, see it here
Enjoy your Reddit Silver, and good luck with the rest of the Advent of Code!
View all comments
Show parent comment
2
u/Tarmen Dec 17 '19 edited Dec 17 '19
I tried to be clever and did something with suffix trees. Later figured out that just limiting the size of the substrings to 2-6 is enough for really fast brute forcing.
https://github.com/Tarmean/AdventOfCode2019/blob/laptop/library/Aoc19_17.hs#L13
Also, being non greedy in applying substitutions without pruning for substring length turned out a bit silly:
Interestingly enough the suffix trees only started working after sorting the entries by
min substring_length occurence_countMy originalsubstring_length * occurence_countto order by coverage was fantastically useless - both really long substrings and single characters cover a lot of the original string.Lost patience when trying to find a way to search a path without cheating and always going forward when possible. aStar with the missing positions in the search state hits an exponential wall hard.