Esempio n. 1
0
        public static void Part2(string[] data)
        {
            List <int> joltageData = new List <int>(Array.ConvertAll(data, s => int.Parse(s)));

            joltageData.Add(0);
            joltageData.Add(joltageData.Max() + 3);

            AdapterChain adapters = new AdapterChain(joltageData);
            long         total    = adapters.CountCombinations();

            Console.WriteLine($"The number of combinations available is: {total}.");
        }
Esempio n. 2
0
        public static void Part1(string[] data)
        {
            List <int> joltageData = new List <int>(Array.ConvertAll(data, s => int.Parse(s)));

            joltageData.Add(0);
            joltageData.Add(joltageData.Max() + 3);

            AdapterChain adapters = new AdapterChain(joltageData);

            (int countOf1Diffs, int countOf3Diffs) = adapters.GetJoltageDiffs();
            int product = countOf1Diffs * countOf3Diffs;

            Console.WriteLine($"There were {countOf1Diffs} 1s and {countOf3Diffs} 3s.");
            Console.WriteLine($"The product of the number of 1 offs and the number of 3 offs is: {countOf1Diffs * countOf3Diffs}.");
        }