private static void Part2() { var lines = File.ReadAllLines("input2.txt"); var hasXyxRule = new HasXyxRule(); var twoLettersAtLeastTwiceRule = new TwoLettersAtLeastTwiceRule(); var rules = new IRule[] {hasXyxRule, twoLettersAtLeastTwiceRule,}; var result = lines.Count(line => rules.All(x => x.Check(line))); Console.WriteLine(result); }
private static void Part1() { var lines = File.ReadAllLines("input1.txt"); var hasVowelsRule = new HasVowelsRule(); var hasAdjacentEqualLettersRule = new HasAdjacentEqualLettersRule(); var doesNotHaveSubstringsRule = new NotRule(new HasSubstrings()); var rules = new IRule[] {hasVowelsRule, hasAdjacentEqualLettersRule, doesNotHaveSubstringsRule,}; var result = lines.Count(line => rules.All(x => x.Check(line))); Console.WriteLine(result); }
public INode Reduce(IRule rule, INodeContext <INode> page) { // sequence with a single item => no sequence needed if (page.Count == 1) { return(page.Get(0)); } var result = new ProtoRule(nameof(Core.Rules.Sequence), rule => new Core.Rules.Sequence(rule.RuleName, rule.All())); result.AddChildren(page.GetAll().Of <ProtoRule>()); return(result); }
public INode Reduce(IRule rule, INodeContext <INode> page) { // choice with a single item => no choice needed if (page.Count == 1) { return(page.Get(0)); } var result = new ProtoRule(nameof(Core.Rules.Choice), rule => new Core.Rules.Choice(rule.RuleName, rule.All())); // filter out the "|" values result.AddChildren(page.GetAll().Of <ProtoRule>()); return(result); }