You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Well to be fair that only one of the winning regexes because they are dynamically created. I iterate changing the values in the curly braces of course (just saying for completeness, even I know nobody would bother to check :)
918
+
919
+
Quite a tough one, but regexes are phenomenal, I never realised they had so much power!
920
+
If I paste this regex in Lea Verou web page regex playground it works!
921
+
https://projects.verou.me/regexplained/
922
+
And they are so fast! How do they accomplish this? 🤔
After updating rules 8 and 11, how many messages completely match rule 0?
141
141
142
+
Your puzzle answer was 184.
143
+
144
+
## Part Two
145
+
146
+
As you look over the list of messages, you realize your matching rules aren't quite right. To fix them, completely replace rules 8: 42 and 11: 42 31 with the following:
147
+
```
148
+
8: 42 | 42 8
149
+
11: 42 31 | 42 11 31
150
+
```
151
+
This small change has a big impact: now, the rules do contain loops, and the list of messages they could hypothetically match is infinite. You'll need to determine how these changes affect which messages are valid.
152
+
153
+
Fortunately, many of the rules are unaffected by this change; it might help to start by looking at which rules always match the same set of values and how those rules (especially rules 42 and 31) are used by the new versions of rules 8 and 11.
154
+
155
+
(Remember, you only need to handle the rules you have; building a solution that could handle any hypothetical combination of rules would be significantly more difficult.)
156
+
157
+
For example:
158
+
```
159
+
42: 9 14 | 10 1
160
+
9: 14 27 | 1 26
161
+
10: 23 14 | 28 1
162
+
1: "a"
163
+
11: 42 31
164
+
5: 1 14 | 15 1
165
+
19: 14 1 | 14 14
166
+
12: 24 14 | 19 1
167
+
16: 15 1 | 14 14
168
+
31: 14 17 | 1 13
169
+
6: 14 14 | 1 14
170
+
2: 1 24 | 14 4
171
+
0: 8 11
172
+
13: 14 3 | 1 12
173
+
15: 1 | 14
174
+
17: 14 2 | 1 7
175
+
23: 25 1 | 22 14
176
+
28: 16 1
177
+
4: 1 1
178
+
20: 14 14 | 1 15
179
+
3: 5 14 | 16 1
180
+
27: 1 6 | 14 18
181
+
14: "b"
182
+
21: 14 1 | 1 14
183
+
25: 1 1 | 1 14
184
+
22: 14 14
185
+
8: 42
186
+
26: 14 22 | 1 20
187
+
18: 15 15
188
+
7: 14 5 | 1 21
189
+
24: 14 1
190
+
191
+
abbbbbabbbaaaababbaabbbbabababbbabbbbbbabaaaa
192
+
bbabbbbaabaabba
193
+
babbbbaabbbbbabbbbbbaabaaabaaa
194
+
aaabbbbbbaaaabaababaabababbabaaabbababababaaa
195
+
bbbbbbbaaaabbbbaaabbabaaa
196
+
bbbababbbbaaaaaaaabbababaaababaabab
197
+
ababaaaaaabaaab
198
+
ababaaaaabbbaba
199
+
baabbaaaabbaaaababbaababb
200
+
abbbbabbbbaaaababbbbbbaaaababb
201
+
aaaaabbaabaaaaababaa
202
+
aaaabbaaaabbaaa
203
+
aaaabbaabbaaaaaaabbbabbbaaabbaabaaa
204
+
babaaabbbaaabaababbaabababaaab
205
+
aabbbbbaabbbaaaaaabbbbbababaaaaabbaaabba
206
+
```
207
+
Without updating rules 8 and 11, these rules only match three messages: `bbabbbbaabaabba`, `ababaaaaaabaaab`, and `ababaaaaabbbaba`.
208
+
209
+
However, after updating rules 8 and 11, a total of 12 messages match:
210
+
```
211
+
bbabbbbaabaabba
212
+
babbbbaabbbbbabbbbbbaabaaabaaa
213
+
aaabbbbbbaaaabaababaabababbabaaabbababababaaa
214
+
bbbbbbbaaaabbbbaaabbabaaa
215
+
bbbababbbbaaaaaaaabbababaaababaabab
216
+
ababaaaaaabaaab
217
+
ababaaaaabbbaba
218
+
baabbaaaabbaaaababbaababb
219
+
abbbbabbbbaaaababbbbbbaaaababb
220
+
aaaaabbaabaaaaababaa
221
+
aaaabbaabbaaaaaaabbbabbbaaabbaabaaa
222
+
aabbbbbaabbbaaaaaabbbbbababaaaaabbaaabba
223
+
```
224
+
After updating rules 8 and 11, how many messages completely match rule 0?
225
+
226
+
Your puzzle answer was 389.
227
+
228
+
Both parts of this puzzle are complete! They provide two gold stars: **
0 commit comments