Community Spring Cleaning week is here! Join your fellow Maveryx in digging through your old posts and marking comments on them as solved. Learn more here!

General Discussions

Discuss any topics that are not product-specific here.

Advent of Code 2020 - BaseA Style (Day 9)

Jean-Balteryx
16 - Nebula
16 - Nebula

Discussion thread for day 9 of the Advent of Code : https://adventofcode.com/2020/day/9

19 REPLIES 19
jdunkerley79
ACE Emeritus
ACE Emeritus

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

Spoiler
jdunkerley79_0-1607492696620.png

 

Greg_Murray
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
Greg_Murray_0-1607493536636.png

iterative macro

Greg_Murray_1-1607493568009.png

 

 

Balders
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
AoC 09.png

 

NicoleJohnson
ACE Emeritus
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. 
Day9.JPG


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

Day9_Macro1.JPG

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

Cheers!

NJ

https://github.com/AlteryxNJ/AdventOfCode_2020 

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

jdunkerley79
ACE Emeritus
ACE Emeritus

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

peter_gb
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
9.png

dsmdavid
11 - Bolide

Not too happy with my solution today... 

Spoiler
dsmdavid_0-1607499740458.png

 

 

T_Willins
14 - Magnetar
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&b Workflow9a Iterative Macro9a Iterative Macro

 

 

9b Iterative Macro9b Iterative Macro

 

Labels