Exemplo n.º 1
0
        private static void Main(string[] pArgs)
        {
            if (!GetArg("puzzleId", pArgs, out string puzzleId))
            {
                Console.WriteLine($"Invalid argument value for 'puzzleId'");
                return;
            }

            BasePuzzle puzzleInstance = InstantiatePuzzle(puzzleId);

            if (puzzleInstance == null)
            {
                Console.WriteLine($"Invalid puzzleId: {puzzleId}");
                return;
            }

            Console.WriteLine($"Execute Puzzle: {puzzleId}");

            string partOneResult = puzzleInstance.SolvePartOne();

            Console.WriteLine($"Part One: {partOneResult}");

            string partTwoResult = puzzleInstance.SolvePartTwo();

            Console.WriteLine($"Part Two: {partTwoResult}");
        }
Exemplo n.º 2
0
        private static BasePuzzle InstantiatePuzzle(string pPuzzleId)
        {
            Type type = Type.GetType($"AoC.{pPuzzleId}.Puzzle");

            if (type == null)
            {
                return(null);
            }

            BasePuzzle puzzle = (BasePuzzle)Activator.CreateInstance(type);

            return(puzzle);
        }