コード例 #1
0
        public void EnumerateParents()
        {
            var map_a = Orbit.BuildOrbitMap(MAP_A);

            map_a["L"].Parents().Select(o => o.Key).Should().ContainInOrder("K", "J", "E", "D", "C", "B", "COM");
            map_a["I"].Parents().Select(o => o.Key).Should().ContainInOrder("D", "C", "B", "COM");
        }
コード例 #2
0
        public void TransferCountShouldBeCorrect()
        {
            var orbit    = Orbit.BuildOrbitMap(MAP_B);
            var distance = orbit.TransfersBetween("YOU", "SAN");

            distance.Should().Be(4);

            orbit    = Orbit.BuildOrbitMap(MAP_C);
            distance = orbit.TransfersBetween("YOU", "SAN");
            distance.Should().Be(7);
        }
コード例 #3
0
        public void BuildPart1ExampleMap()
        {
            var orbit = Orbit.BuildOrbitMap(MAP_A);

            orbit.Key.Should().Be("COM");
            orbit.Parent.Should().Be(orbit);
            orbit["B"].Children.Select(o => o.Key).Should().ContainInOrder("C", "G");
            orbit["L"].Parent.Should().Be(orbit["K"]);
            orbit["L"].Depth.Should().Be(7);
            orbit["D"].Depth.Should().Be(3);
            orbit.TotalOrbits().Should().Be(42);
        }
コード例 #4
0
        static void Day6()
        {
            WriteLine("--- Day 6: Universal Orbit Map ---");
            var map    = "Day6/input.txt".ReadLines();
            var orbit  = Orbit.BuildOrbitMap(map);
            var result = orbit.TotalOrbits();

            WriteLine(result);

            var distance = orbit.TransfersBetween("YOU", "SAN");

            WriteLine(distance);
        }