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

Alteryx Certified Partner

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

16 - Nebula
16 - Nebula

Regex to the rescue...

Spoiler
As the problem said don't solve the general case for Part 2!

A bit of thinking and then broke Part 2 into 2 blocks which was a lot easier!

The generated Regexes are horrible but work

jdunkerley79_0-1608362484962.png

 

 

8 - Asteroid

Surprisingly simple solution in the end after a lot of troubleshooting. It works for both parts and can be turned into a macro-free solution.

 

Macro solution:

Spoiler
stephM_0-1608376504609.png

Macro-free solution:

Spoiler
stephM_1-1608376590805.png

 

Alteryx Certified Partner

Very similar to the both of you and I think I've made more iterative macros this month than I ever have in day to day Alteryx use!

 

Spoiler
Workflow:

For part 2 I evaluated for "^[042]+[031]+$" where the [042]+ was longer than the [031]+.

AoC 19.pngMacroAoC 19 Macro.png
Alteryx Partner

Also a "bit" of regex... I used two iteratives: one to generate rule 0 and another to beautify the regex expression (remove extra brackets).

The same workflow works for both parts, after manual update of the rules... It took me a lot of trial and error to get it working for the updated rule 11. But regular-expression.info to the rescue. 

Spoiler
Alteryx_Day_19.pngThe updated rules for part II:
rule 8 is the same as (42)+
and rule 11 has a recursive (which took me ages to finally get it working): 
dsmdavid_0-1608395976082.png

 


 
dsmdavid_0-1608394237795.png
Mixed feelings about hardcoding the new rules--e.g. this would not work for a random rule that has a loop, but:
dsmdavid_1-1608395430772.png

 

 
 

Final Regex

Spoiler
Day_19_Regex.png
Alteryx Certified Partner

I'm not sure I understood everything I did about Regex but eventually I got there, discovering recursive regex on the way.

 

Capture d’écran 2020-12-20 à 00.36.04.pngCapture d’écran 2020-12-20 à 00.37.12.png

Alteryx Certified Partner

@dsmdavid lovely recursive regex I'd have never have worked that out