part2 (2445B)
1--- Part Two --- 2 3As you look over the list of messages, you realize your matching rules aren't quite right. To fix 4them, completely replace rules 8: 42 and 11: 42 31 with the following: 5 68: 42 | 42 8 711: 42 31 | 42 11 31 8 9This small change has a big impact: now, the rules [1m[37mdo[0m contain loops, and the list of 10messages they could hypothetically match is infinite. You'll need to determine how these changes 11affect which messages are valid. 12 13Fortunately, many of the rules are unaffected by this change; it might help to start by looking at 14which rules always match the same set of values and how [1m[37mthose[0m rules (especially rules 1542 and 31) are used by the new versions of rules 8 and 11. 16 17(Remember, [1m[37myou only need to handle the rules you have[0m; building a solution that could 18handle any hypothetical combination of rules would be significantly more difficult.) 19 20For example: 21 2242: 9 14 | 10 1 239: 14 27 | 1 26 2410: 23 14 | 28 1 251: "a" 2611: 42 31 275: 1 14 | 15 1 2819: 14 1 | 14 14 2912: 24 14 | 19 1 3016: 15 1 | 14 14 3131: 14 17 | 1 13 326: 14 14 | 1 14 332: 1 24 | 14 4 340: 8 11 3513: 14 3 | 1 12 3615: 1 | 14 3717: 14 2 | 1 7 3823: 25 1 | 22 14 3928: 16 1 404: 1 1 4120: 14 14 | 1 15 423: 5 14 | 16 1 4327: 1 6 | 14 18 4414: "b" 4521: 14 1 | 1 14 4625: 1 1 | 1 14 4722: 14 14 488: 42 4926: 14 22 | 1 20 5018: 15 15 517: 14 5 | 1 21 5224: 14 1 53 54abbbbbabbbaaaababbaabbbbabababbbabbbbbbabaaaa 55bbabbbbaabaabba 56babbbbaabbbbbabbbbbbaabaaabaaa 57aaabbbbbbaaaabaababaabababbabaaabbababababaaa 58bbbbbbbaaaabbbbaaabbabaaa 59bbbababbbbaaaaaaaabbababaaababaabab 60ababaaaaaabaaab 61ababaaaaabbbaba 62baabbaaaabbaaaababbaababb 63abbbbabbbbaaaababbbbbbaaaababb 64aaaaabbaabaaaaababaa 65aaaabbaaaabbaaa 66aaaabbaabbaaaaaaabbbabbbaaabbaabaaa 67babaaabbbaaabaababbaabababaaab 68aabbbbbaabbbaaaaaabbbbbababaaaaabbaaabba 69 70Without updating rules 8 and 11, these rules only match three messages: bbabbbbaabaabba, 71ababaaaaaabaaab, and ababaaaaabbbaba. 72 73However, after updating rules 8 and 11, a total of [1m[37m12[0m messages match: 74 75 76 - bbabbbbaabaabba 77 - babbbbaabbbbbabbbbbbaabaaabaaa 78 - aaabbbbbbaaaabaababaabababbabaaabbababababaaa 79 - bbbbbbbaaaabbbbaaabbabaaa 80 - bbbababbbbaaaaaaaabbababaaababaabab 81 - ababaaaaaabaaab 82 - ababaaaaabbbaba 83 - baabbaaaabbaaaababbaababb 84 - abbbbabbbbaaaababbbbbbaaaababb 85 - aaaaabbaabaaaaababaa 86 - aaaabbaabbaaaaaaabbbabbbaaabbaabaaa 87 - aabbbbbaabbbaaaaaabbbbbababaaaaabbaaabba 88 89 90[1m[37mAfter updating rules 8 and 11, how many messages completely match rule 0?[0m 91 92