Пример #1
0
        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
        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);
        }