General Discussions

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

General Discussions has some can't miss conversations going on right now! From conversations about automation to sharing your favorite Alteryx memes, there's something for everyone. Make it part of your community routine!

Advent of Code 2020 - BaseA Style (Day 19)

Jean-Balteryx
13 - Pulsar

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

jdunkerley79
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

 

 

stephM
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

 

Balders
10 - Fireball

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
dsmdavid
11 - Bolide

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
Jean-Balteryx
13 - Pulsar

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

Balders
10 - Fireball

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