This site uses different types of cookies, including analytics and functional cookies (its own and from other sites). To change your cookie settings or find out more, click here. If you continue browsing our website, you accept these cookies.
We are updating the requirements for Community registration. As of 7/21/21 all users will be required to register a phone number with their My Alteryx accounts. If you have already registered, you will be prompted on your next login to add your phone number.
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...
Approach for this one was to do the iterating within the macros, but do the final calc for Part 2 in the base workflow for expediency. Overall, about a minute & a half to run - not fast, but since I was able to get there more or less on the first pass/without having to run it multiple times, it worked out OK.
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.
@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.
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).