alteryx Community

# General Discussions

Discuss any topics that are not product-specific here.

## Advent of Code 2020 - BaseA Style (Day 9)

16 - Nebula

19 REPLIES 19
ACE Emeritus

Time for a workflow constant (number of rows to look back) to allow for some testing.

Spoiler

12 - Quasar

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.

Spoiler

iterative macro

11 - Bolide

Here's me. I found part 2 easier to set up than part 1, maybe I'd just woken up a bit.

Spoiler

ACE Emeritus

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...

Spoiler
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.

Cheers!

NJ

11 - Bolide

@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.

ACE Emeritus

Thanks @Balders  - and yes agree we haven't had a major scale issue yet. Was about now in 2018 started getting those.

9 - Comet

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

Spoiler

11 - Bolide

Not too happy with my solution today...

Spoiler

14 - Magnetar

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).

Spoiler
9a&b Workflow9a Iterative Macro

9b Iterative Macro

Labels