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)

Jean-Balteryx
15 - Aurora

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

11 REPLIES 11
Balders
11 - Bolide

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

Spoiler
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.
jdunkerley79
16 - Nebula
16 - Nebula

Regex and substrings everywhere... 0.6s tho

Spoiler
jdunkerley79_0-1608281495502.png
Internal macro
jdunkerley79_1-1608281565903.png

 

 

Balders
11 - Bolide

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

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

 

Spoiler
workflow 
Greg_Murray_0-1608299498865.png


Parenthesis Grouping Macro

Greg_Murray_1-1608299579424.png

Part 1 Iterative

Greg_Murray_2-1608299658050.png

Part 2 Iterative

Greg_Murray_3-1608299717666.png

 

 

patrick_digan
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

Spoiler
patrick_digan_0-1608305756341.png

 

AkimasaKajitani
15 - Aurora

Day18!

 

Today I don't use any macro...

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


AkimasaKajitani_0-1608308698547.png

 

AS anonymous user #1105310

https://github.com/AkimasaKajitani/AdventOfCode

 

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

Spoiler
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


Previous

Alteryx_Day_18.png

 

I again created the iterative first, then the generate rows

Spoiler
dsmdavid_1-1608317657307.pngdsmdavid_2-1608317701897.png

 

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

 

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

 

Spoiler
MacroMacroMainMain

Dan

 

 

Jean-Balteryx
15 - Aurora

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

 

Spoiler
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