Exemplo n.º 1
0
        public void Part2_WithSampleInput_ShouldReturn8()
        {
            string sampleInput = @"16
                10
                15
                5
                1
                11
                7
                19
                6
                12
                4";

            string[] input = new List <string>(
                sampleInput.Split(Environment.NewLine,
                                  StringSplitOptions.TrimEntries |
                                  StringSplitOptions.RemoveEmptyEntries
                                  )
                )
                             .ToArray();
            List <int> joltageData = new List <int>(Array.ConvertAll(input, s => int.Parse(s)));

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

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

            Assert.Equal(8, total);
        }
Exemplo n.º 2
0
        public void Part2_WithSecondSampleInput_ShouldReturn19208()
        {
            string sampleInput = @"28
                33
                18
                42
                31
                14
                46
                20
                48
                47
                24
                23
                49
                45
                19
                38
                39
                11
                1
                32
                25
                35
                8
                17
                7
                9
                4
                2
                34
                10
                3";

            string[] input = new List <string>(
                sampleInput.Split(Environment.NewLine,
                                  StringSplitOptions.TrimEntries |
                                  StringSplitOptions.RemoveEmptyEntries
                                  )
                )
                             .ToArray();
            List <int> joltageData = new List <int>(Array.ConvertAll(input, s => int.Parse(s)));

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

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

            Assert.Equal(19208, total);
        }