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

                new OrbitDesc("E")
                {
                    Orbiter = "F"
                },
                new OrbitDesc("COM")
                {
                    Orbiter = "B"
                },
                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"
                },
                new OrbitDesc("D")
                {
                    Orbiter = "E"
                },
            };

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

            map.AddListToGraph(head, input);
            Assert.That(map.FindNode(head, "K").Orbiters.First().Center, Is.EqualTo("L"));
        }
Exemplo n.º 2
0
        public void ImportDataAndFindDistBetweenYouAndSanTest()
        {
            string filePath = @"AdventOfCode2019/InputData/Day6Orbits.txt";

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

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

            head = map.AddListToGraph(head, input.ToList());
            var sanNode = map.FindNode(head, "SAN");

            var distBetweenYouAndSan      = map.CountDistanceBetweenPoints(sanNode, "YOU");
            var distBetweenOrbitingBodies = distBetweenYouAndSan - 2;

            Assert.That(distBetweenOrbitingBodies, Is.EqualTo(385));
        }
Exemplo n.º 3
0
        public void DistBetweenYouAndSanTest()
        {
            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"
                },
                new OrbitDesc("K")
                {
                    Orbiter = "YOU"
                },
                new OrbitDesc("I")
                {
                    Orbiter = "SAN"
                }
            };

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

            head = map.AddListToGraph(head, input);
            var sanNode = map.FindNode(head, "SAN");

            var distBetweenYouAndSan      = map.CountDistanceBetweenPoints(sanNode, "YOU");
            var distBetweenOrbitingBodies = distBetweenYouAndSan - 2;

            Assert.That(distBetweenOrbitingBodies, Is.EqualTo(4));
        }