Advent of Code 2020 - BaseA Style (Day 19)
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Discussion thread for day 19 of the Advent of Code : https://adventofcode.com/2020/day/19
- Labels:
- Advent of Code
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Regex to the rescue...
A bit of thinking and then broke Part 2 into 2 blocks which was a lot easier!
The generated Regexes are horrible but work
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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!
For part 2 I evaluated for "^[042]+[031]+$" where the [042]+ was longer than the [031]+.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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.
rule 8 is the same as (42)+
and rule 11 has a recursive (which took me ages to finally get it working):
Mixed feelings about hardcoding the new rules--e.g. this would not work for a random rule that has a loop, but:
Final Regex
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
I'm not sure I understood everything I did about Regex but eventually I got there, discovering recursive regex on the way.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
@dsmdavid lovely recursive regex I'd have never have worked that out
