Exemplo n.º 1
0
        public static void Part_1(string input, bool pretty)
        {
            Dictionary <string, c_cave> caves = parse_input(input);

            // compute paths

            c_cave start_cave = caves["start"];
            c_cave end_cave   = caves["end"];

            HashSet <string> paths = new HashSet <string>();

            start_cave.get_paths(end_cave, ref paths);

            // Display output

            Console.ForegroundColor = ConsoleColor.Gray;
            foreach (string path in paths)
            {
                Console.WriteLine(path);
            }

            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine();
            Console.WriteLine("Result = {0}", paths.Count);
            Console.ResetColor();
        }
Exemplo n.º 2
0
        public static void Part_2(string input, bool pretty)
        {
            Dictionary <string, c_cave> caves = parse_input(input);

            // compute paths

            c_cave start_cave = caves["start"];
            c_cave end_cave   = caves["end"];

            HashSet <string> paths = new HashSet <string>();

            foreach (c_cave cave in caves.Values)
            {
                if (cave.size == e_cave_size.small && cave != start_cave && cave != end_cave)
                {
                    cave.size = e_cave_size.medium;

                    start_cave.get_paths(end_cave, ref paths);

                    cave.size = e_cave_size.small;
                }
            }

            start_cave.get_paths(end_cave, ref paths);

            // Display output

            Console.ForegroundColor = ConsoleColor.Gray;
            foreach (string path in paths)
            {
                Console.WriteLine(path);
            }

            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine();
            Console.WriteLine("Result = {0}", paths.Count);
            Console.ResetColor();
        }