Now that it's live, don't forget to accept your certification badge on Credly today! Learn more here.

General Discussions

Discuss a wide range of topics! Questions about the Alteryx Platform should be directed to the appropriate Product discussion forum.

Advent of Code 2020 - BaseA Style (Day 18)

15 - Aurora

Discussion thread for day 18 of the Advent of Code :

11 - Bolide

Here's me, lots of lovely regex today. 1.4s runtime. 

My parent workflow is pretty clean with just a data cleanse to remove white space, then my two iterative macros. My second macro has a debugging output which was useful to find where my order of operations was out in certain scenarios.
Day 18 Parent Workflow.png
Macro 1 Steps:
1) remove parentheses from any single number, e.g. (10) -> 10
2) parse the resulting text to split for the first operation found
3) if no operation is found, we only have a whole number so send it to output
4) calculate first operation and bring string back together. e.g. 4+6*3 -> 10*3
5) repeat until all operations processed

Day 18 macro 1.png

Macro 2. This is a little bit more involved due to the stricter order of operations. The steps here are:
1) remove single number parentheses
2) create waterfall of filters based on order of ops
2.1) any plain addition, e.g. 3*6+4 -> 3*10
2.2) contains addition but needs multiplication in parentheses done first. e.g. (3*6)+4 -> 18+4
2.3) only multiplaction left
2.4) only whole numbers -> output result
3) iteration outputs
3.1) send new strings back to repeat process
3.2) output all strings from each iteration, this helped with debugging and getting the parse logic correct for 2.2
Day 18 macro 2.png

I tried at first in macro 1 to do the regex parsing and function all in one formula tool along the lines of this
regex_replace([data],"(.*?)(\d+)([\+\*])(\d+)(\.*)", "$1" +ToString(ToNumber("$2")...​

But I came up short so if anyone can smush the parsing and operation into one formula tool I'd love to see it.
16 - Nebula
16 - Nebula

Regex and substrings everywhere... 0.6s tho

Internal macro



11 - Bolide

@jdunkerley79 neat. I couldn't work out getting into fewer formula tools. 

12 - Quasar

Here is my solve. It's a bit 'tooly'. I figured there was a better way to solve this after I was an hour in, but by that point in the evening I was too stubborn and tired to turn back. 


Thanks for detailing your solve @Balders. I may give it another go with a similar strategy.


Anyway, I ended up with 3 iterative macros; one to solve the parenthesis groupings and the other two to apply the logic for either part. 



Parenthesis Grouping Macro


Part 1 Iterative


Part 2 Iterative




16 - Nebula
16 - Nebula

I solved the problem via brute force and lots of copying and pasting tools instead of a macro. I'm posting my workflow here for comedic relief



15 - Aurora



Today I don't use any macro...

Each color Boxes are almost the same and I think it can merge to the Iterative macro. But I didn't use the Iterative Macro to make it easier to debug.



AS anonymous user #1105310


11 - Bolide

I'm trying to understand better how to replace macros with combinations of generate rows & multirows. Having fun even if the formulas inside are terrible to debug...(can't imagine inheriting one workflow where someone did something like this...)

Not entirely sure of why I need that formula tool to calculate the result for the last row. Why doesn't the generate rows go one extra row?
EDIT: I solved it by adding an || to the condition. dsmdavid_0-1608325608952.png




I again created the iterative first, then the generate rows



My regex is so so, and probably overcomplicated the formula, will need to investigate that neat workflow by @jdunkerley79  🙂


18 - Pollux
18 - Pollux

Here's part 1.  After making the effort to minimize the use of macros in previous days, I just gave in today and built an iterative one in about the same time that it takes me to ensure that the parentheses line up in nested IIF statements in the non-macro versions built previously.  Runs quickly as well, 0.3s, since it only iterates once per level of parentheses and my input set was never nested more that 2 deep.






15 - Aurora

Went for iterative combination again ... Will try to make one with route option.


Capture d’écran 2020-12-18 à 23.56.21.pngCapture d’écran 2020-12-18 à 23.57.34.pngCapture d’écran 2020-12-18 à 23.59.41.png