Advent of Code 2020 - BaseA Style (Day 9)
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Discussion thread for day 9 of the Advent of Code : https://adventofcode.com/2020/day/9
- Labels:
- Advent of Code
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Time for a workflow constant (number of rows to look back) to allow for some testing.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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).
Iterative Macro for Part 2: Using the value from Part 1, created an iterative macro that calculates the running total of all (remaining) records, tries to match that to the desired value from Part 1, and then removes the first record before the next iteration. Included the "escape logic" in this one as well so that it would stop iterating once a match was found.
Cheers!
NJ
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
@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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Thanks @Balders - and yes agree we haven't had a major scale issue yet. Was about now in 2018 started getting those.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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).
