/// <summary> /// https://adventofcode.com/2020/day/19#part2 /// </summary> public static void Part2() { var groups = Input.GetGroups(19); var ruleSet = MessageRuleSet.Parse(groups[0]); var inputs = groups[1].Split('\n'); ruleSet[8] = MessageRule.Parse("42 | 42 8"); ruleSet[11] = MessageRule.Parse("42 31 | 42 11 31"); var count = inputs.Count(ruleSet[0].Matches); Console.WriteLine(count); }
public void Part2Test() { // Given var groups = Input.GetGroups(19, "Part2"); var ruleSet = MessageRuleSet.Parse(groups[0]); var inputs = groups[1].Split('\n'); // When var oldCount = inputs.Count(ruleSet[0].Matches); ruleSet[8] = MessageRule.Parse("42 | 42 8"); ruleSet[11] = MessageRule.Parse("42 31 | 42 11 31"); var newCount = inputs.Count(ruleSet[0].Matches); // Then Assert.Equal(3, oldCount); Assert.Equal(12, newCount); }