Exemple #1
0
        public void RunPart1()
        {
            const int totalSought = 2020;

            var pairs = new SumFinder().FindPairsThatSumToTotal(Input, totalSought);

            if (pairs.Count != 1)
            {
                Console.WriteLine("Internal or data error");
                return;
            }

            foreach (var pair in pairs)
            {
                Console.WriteLine($"{pair.Item1} + {pair.Item2} = {totalSought}. {pair.Item1}*{pair.Item2} = {pair.Item1 * pair.Item2}");
            }
        }
Exemple #2
0
        public void RunPart2()
        {
            const int totalSought = 2020;

            var triples = new SumFinder().FindTriplesThatSumToTotal(Input, totalSought);

            if (triples.Count != 1)
            {
                Console.WriteLine("Internal or data error");
                return;
            }

            foreach (var triple in triples)
            {
                Console.WriteLine($"{triple.Item1} + {triple.Item2} + {triple.Item3} = {totalSought}. {triple.Item1}*{triple.Item2} = {triple.Item1 * triple.Item2 * triple.Item3}");
            }
        }