public GeneratedResultWindow(Record record) : this()
        {
            var formatter = new RecordFormatter(record);

            EmploymentBox.Text = formatter.EmploymentRecords;
            MedicalBox.Text    = formatter.MedicalRecords;
            SecurityBox.Text   = formatter.SecurityRecords;
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            // Doing a thing.
            var formatter = new RecordFormatter(new FileReader());
            var records   = formatter.FormatFile(@"C:\Dev\GitHub\AdventOfCode2020\Day4\Data\input", "\n\n", true).Select(s => new NorthPoleCredential(s));

            var validRecords = records.Where(r => r.Valid).Count();

            Console.WriteLine(validRecords);

            var extendedValidRecords = records.Where(r => r.ExtendedValidation).Count();

            Console.WriteLine(extendedValidRecords);
        }
Exemplo n.º 3
0
        /// <summary>
        /// TuringBusses.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(reader);
            var records   = formatter.FormatFile(filePath, "\n", true);

            var timeStamp = int.Parse(records.First());

            var scheduler = new BusScheduler(formatter);

            var product = scheduler.GetNextBusProduct(timeStamp, records.Skip(1).First());

            Console.WriteLine(product);

            var timeStamp2 = scheduler.WinContest(records.Skip(1).First());

            Console.WriteLine(timeStamp2);
        }
Exemplo n.º 4
0
        /// <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());
        }
Exemplo n.º 5
0
        /// <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);
        }