コード例 #1
0
        static void PartTwo()
        {
            Console.WriteLine("--- Part 2 ---");

            var scan = new BoxScan();

            Console.WriteLine("Scanning box IDs...");
            var ids = scan.GetBoxIds();

            Console.WriteLine("Finding similiar IDs...");
            var data = scan.FindCommonLetters(ids);

            Console.WriteLine("Finding common letters...");
            var commonLetters = scan.RemoveDifferentLetters(data.Item1, data.Item2);

            Console.WriteLine($"The common letters are: {commonLetters}");
        }
コード例 #2
0
        static void PartOne()
        {
            Console.WriteLine("--- Day 2 ---");
            Console.WriteLine("--- Part 1 ---");

            var scan = new BoxScan();

            Console.WriteLine("Scanning box IDs...");
            var ids = scan.GetBoxIds();

            Console.WriteLine("Counting letters that appears twice...");
            var first = scan.CountMultipleAppearingLetters(ids, 2);

            Console.WriteLine("Counting letters that appears three times...");
            var second = scan.CountMultipleAppearingLetters(ids, 3);

            Console.WriteLine("Generating checksum...");
            var checksum = scan.GenerateBoxCheckSum(first, second);

            Console.WriteLine($"Checksum is {checksum}");
        }