Discussion thread for day 9 of the Advent of Code : https://adventofcode.com/2020/day/9
Time for a workflow constant (number of rows to look back) to allow for some testing.
I took the iterative route for part one and brute force for part two, which was not fast at all. Interested in seeing the other (read: quicker) solves.
iterative macro
My solution! Not as thrilling as Day 8 (dare I say I was even a bit disappointed to have mentally prepped myself for Intcode V2, just to have today's challenge NOT be a repeat of Day 8??)... but was still able to solve with a pair of iterative macros and only a minor amount of brute force in testing them...
Iterative Macro for Part 1: General gist of it is to take the first 25 rows, find all the valid combinations of record pairs, add them up, then compare value to the 26th row. Built in logic at the end to remove first record for each iteration, but also to escape out of the iterative macro once a match was *not* found (so I don't actually have to iterate through all possible iterations and can stop once my objective is reached).
Cheers!
NJ
@jdunkerley79 that's a very elegant solution to part 2 without exploding the number of records 👏
I find with this advent that because the data sets are never very large we can take liberties with memory usage to crank out an answer but its cool to see a solution there that would scale to much larger data sets.
Thanks @Balders - and yes agree we haven't had a major scale issue yet. Was about now in 2018 started getting those.
Still feeling quite brute forcey! Nice to not spend hours on today's though...
Generate all for part 1
Iterative macro for part 2 which still ran <6 seconds so not horrible
Pretty happy with my results today. While I did use iterative macros for both parts it runs about 40 seconds. Channeled the use of the Multi-Row Formula from @NicoleJohnson and @NedHarding on Part 8 to generate the solutions for my 9a iterative macro. Stir in a little parsing and it all worked (after period of frustration when I didn't set the Multi-Field formula to a large enough size).