Esempio n. 1
0
        public static void PartTwo()
        {
            Console.WriteLine("Day four - Part Two");
            List <List <string> > lines     = PuzzleInputHelper.GetInputLinesBatched("DayFour.txt", String.Empty);
            List <Passport>       passports = lines.Select(Passport.FromLines).ToList();

            Console.WriteLine($"There are only {passports.Count(p => p.IsDataValid())} data-valid passports");
            Console.WriteLine("Day four - End of part Two");
        }
Esempio n. 2
0
        public static void PartTwo()
        {
            Console.WriteLine("Day six - Part Two");
            List <List <string> > lines         = PuzzleInputHelper.GetInputLinesBatched("DaySix.txt", String.Empty);
            List <string>         uniqueAnswers = new List <string>();

            lines.Aggregate(uniqueAnswers, (ua, answers) => {
                ua.Add(String.Join("", String.Join("", answers).Distinct()));
                return(ua);
            });
            int sum = lines.Zip(uniqueAnswers, (answers, ua) => ua.Count(c => String.Join("", answers).Count(a => a == c) == answers.Count)).Sum();

            Console.WriteLine($"Sum of all groups count is {sum}");
            Console.WriteLine("Day six - End of Part Two");
        }
Esempio n. 3
0
        public static void PartOne()
        {
            Console.WriteLine("Day six - Part One");
            List <List <string> > lines         = PuzzleInputHelper.GetInputLinesBatched("DaySix.txt", String.Empty);
            List <string>         uniqueAnswers = new List <string>();

            lines.Aggregate(uniqueAnswers, (ua, answers) => {
                ua.Add(String.Join("", String.Join("", answers).Distinct()));
                return(ua);
            });
            int sumOfUniqueAnswers = uniqueAnswers.Sum(ua => ua.Length);

            Console.WriteLine($"Unique answers for first group is {uniqueAnswers[0]}");
            Console.WriteLine($"Sum of all groups count is {sumOfUniqueAnswers}");
            Console.WriteLine("Day six - End of part One");
        }