コード例 #1
0
        private static int SolvePartOne(IEnumerable <string> rawRules, IEnumerable <string> messages)
        {
            var validator = new RuleValidator(rawRules);

            return(validator
                   .ValidateMessages(messages)
                   .Count());
        }
コード例 #2
0
        private static int SolvePartTwo(IEnumerable <string> rawRules, IEnumerable <string> messages)
        {
            rawRules = rawRules
                       .Where(rule => !rule.StartsWith("8:") && !rule.StartsWith("11:"))
                       .Append("8: 42 | 42 8")
                       .Append("11: 42 31 | 42 11 31");

            var validator = new RuleValidator(rawRules);

            return(validator
                   .ValidateMessages(messages)
                   .Count());
        }