/// <summary> /// PapersPlease.Cmd entry point /// </summary> /// <param name="args">Command line arguments (not used)</param> static void Main(string[] args) { var filePath = "./input"; var reader = new FileReader(); var formatter = new RecordFormatter(new FileReader()); var fileString = reader.ReadFile(filePath).Replace("\r", string.Empty); var groupStrings = formatter .FormatRecord( fileString, "\n\n", true ); var groups = formatter.FormatSubRecords(groupStrings, "\n", true) .Select( record => new PassengerGroup(record) ); Console.WriteLine(groups.Select(group => group.DistinctAnswerCount).Sum()); Console.WriteLine(groups.Select(group => group.AllSameAnswerCount).Sum()); }
/// <summary> /// Bagr.Cmd entry point /// </summary> /// <param name="args">Command line arguments (not used)</param> static void Main(string[] args) { var filePath = "./input"; var reader = new FileReader(); // Normalize line endings. Bake this into the fileReader class soon. var contents = reader.ReadFile(filePath).Replace("\r\n", "\n"); var formatter = new RecordFormatter(null); var ruleStrings = formatter.FormatRecord(contents, "\n", true); var parser = new RuleParser(); var parsedRules = parser.ParseRules(ruleStrings); var bagColors = parser.FindBagColorsContainingBag(parsedRules, "shiny gold"); Console.WriteLine(bagColors.Count()); // Subtract 1 because we only care about what's in our bag var sumOfContents = parser.FindSumOfContents(parsedRules, "shiny gold") - 1; Console.WriteLine(sumOfContents); }