Discussion thread for day 19 of the Advent of Code : https://adventofcode.com/2020/day/19
Regex to the rescue...
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:
Macro-free solution:
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.
Final Regex
I'm not sure I understood everything I did about Regex but eventually I got there, discovering recursive regex on the way.
@dsmdavid lovely recursive regex I'd have never have worked that out