Exemplo n.º 1
0
        public void SumDirectIndirectOrbitsTest()
        {
            List <OrbitDesc> input = new List <OrbitDesc>
            {
                new OrbitDesc("COM")
                {
                    Orbiter = "B"
                },
                new OrbitDesc("B")
                {
                    Orbiter = "C"
                },
                new OrbitDesc("C")
                {
                    Orbiter = "D"
                },
                new OrbitDesc("D")
                {
                    Orbiter = "E"
                },
                new OrbitDesc("E")
                {
                    Orbiter = "F"
                },

                new OrbitDesc("B")
                {
                    Orbiter = "G"
                },
                new OrbitDesc("G")
                {
                    Orbiter = "H"
                },

                new OrbitDesc("D")
                {
                    Orbiter = "I"
                },
                new OrbitDesc("E")
                {
                    Orbiter = "J"
                },
                new OrbitDesc("J")
                {
                    Orbiter = "K"
                },
                new OrbitDesc("K")
                {
                    Orbiter = "L"
                }
            };

            var head = new Node("COM");
            Day6UniversalOrbitMap map = new Day6UniversalOrbitMap();

            head = map.AddListToGraph(head, input);
            Assert.That(map.CountTotalOrbits(head), Is.EqualTo(42));
        }
Exemplo n.º 2
0
        public void ImportDataAndSumDirectIndirectOrbitsTest()
        {
            string filePath = @"AdventOfCode2019/InputData/Day6Orbits.txt";

            Day6UniversalOrbitMap   map   = new Day6UniversalOrbitMap();
            IEnumerable <OrbitDesc> input =
                ReadInputFromFile.ReadFile(new FileInfo(filePath));

            var head = new Node("COM");

            head = map.AddListToGraph(head, input.ToList());
            Assert.That(map.CountTotalOrbits(head), Is.EqualTo(234446));
        }