Exemplo n.º 1
0
        public Day19() : base(19, 2020, "")
        {
            string[] problemParts = Input.Split("\n\n");

            foreach (string line in problemParts[0].Split("\n"))
            {
                new StringRule(line);
            }

            int countOne = 0;
            int countTwo = 0;

            // Get the sets of rules we care about
            HashSet <string> baseRule  = StringRule.GetMatches(0);
            HashSet <string> frontRule = StringRule.GetMatches(42);
            HashSet <string> backRule  = StringRule.GetMatches(31);

            // Check each string in the input
            foreach (string line in problemParts[1].Split("\n"))
            {
                if (baseRule.Contains(line))
                {
                    countOne++;
                }
                if (PartTwoMatches(line, frontRule, backRule, 0))
                {
                    countTwo++;
                }
            }

            partOne = countOne.ToString();
            partTwo = countTwo.ToString();
        }