I also used Go - my solution for part 1 was essentially identical to yours. I went a different route for part 2 that I think ended up being simpler though.
I just prepended do() and don't() to the original regex with a |, that way it captured all 3 in order and I just looped through all the matches once and toggled the isEnabled flag accordingly.
Always interesting to see how other people tackle the same problem!
I also used Go - my solution for part 1 was essentially identical to yours. I went a different route for part 2 that I think ended up being simpler though.
I just prepended
do()
anddon't()
to the original regex with a|
, that way it captured all 3 in order and I just looped through all the matches once and toggled theisEnabled
flag accordingly.Always interesting to see how other people tackle the same problem!