コード例 #1
0
ファイル: Day18.cs プロジェクト: erjicles/AdventOfCode2019
        public static int GetDay18Part2Answer()
        {
            // After updating your map and using the remote-controlled robots,
            // what is the fewest steps necessary to collect all of the keys?
            // Answer: 1538
            var mazeDefinition   = GetDay18Input();
            var maze             = new Maze(mazeDefinition, true);
            var initialMazeState = new MazeState(maze, maze.StartingPositions, new SortedDictionary <string, string>());

            initialMazeState.DrawMazeState();
            var shortestPath = GetShortestPathToCollectAllKeys(maze);

            Console.WriteLine($"{MazeState.GetPathString(shortestPath.Path, false)}");
            var result = shortestPath.TotalPathCost;

            return(result);
        }
コード例 #2
0
ファイル: Day18.cs プロジェクト: erjicles/AdventOfCode2019
        public static int GetDay18Part1Answer()
        {
            // How many steps is the shortest path that collects all of the keys?
            // Answer: 3216
            var mazeDefinition   = GetDay18Input();
            var maze             = new Maze(mazeDefinition);
            var initialMazeState = new MazeState(maze, maze.StartingPositions, new SortedDictionary <string, string>());

            initialMazeState.DrawMazeState();
            var shortestPath = GetShortestPathToCollectAllKeys(maze);

            Console.WriteLine($"{MazeState.GetPathString(shortestPath.Path, false)}");
            var result = shortestPath.TotalPathCost;

            //var result = 3216;
            return(result);
        }