예제 #1
0
 static void Main(string[] args)
 {
     Console.WriteLine($"Day 1: {Day1.Solve()}");
     Console.WriteLine($"Day 2: {Day2.Solve()}");
     Console.WriteLine($"Day 3: {Day3.Solve()}");
     Console.WriteLine($"Day 4: {Day4.Solve()}");
     Console.WriteLine($"Day 5: {string.Join(", ", Day5.Solve())}");
     Console.WriteLine($"Day 6: {Day6.Solve()}");
 }
예제 #2
0
        public static void SafeSolve(string input)
        {
            try
            {
                if (ValidateInput(input))
                {
                    Console.WriteLine($"Solving day {SafeGetDay(input)}, part {SafeGetPart(input)}");
                    switch (input)
                    {
                    case "1.1":
                        Day1.Solve("Data/D1P1.txt");
                        break;

                    case "1.2":
                        Day1.Solve("Data/D1P1.txt", true);
                        break;

                    case "2.1":
                        Day2.Solve("Data/D2P1.txt");
                        break;

                    case "2.2":
                        Day2.Solve("Data/D2P1.txt", true);
                        break;

                    case "3.1":
                        Day3.Solve("Data/D3P1.txt", true);
                        break;

                    case "4.1":
                        Day4.Solve("Data/D4P1.txt");
                        break;

                    case "4.2":
                        Day4.Solve("Data/D4P1.txt", true);
                        break;

                    case "5.1":
                        Day5.Solve("Data/D5P1.txt");
                        break;

                    case "5.2":
                        Day5.Solve("Data/D5P1.txt", true);
                        break;

                    case "7.1":
                        Day7.Solve("Data/D7P1.txt");
                        break;

                    case "7.2":
                        Day7.Solve("Data/D7P1.txt", true);
                        break;

                    default:
                        Console.WriteLine("No puzzle found for specified date. Try again.");
                        break;
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine($"We done goofed on day {SafeGetDay(input)}. " + e.Message);
            }
        }
예제 #3
0
        static void PrintSolution(int day)
        {
            switch (day)
            {
            case 1:
                Console.WriteLine("\nSolving Day 1....");
                Console.WriteLine($"Solution to part 1: {Day1.SolvePart1()}\n");
                Console.WriteLine($"Solution to part 2: {Day1.SolvePart2()}\n");
                break;

            case 2:
                Console.WriteLine("\nSolving Day 2....");
                Console.WriteLine($"Solution to part 1: {Day2.Solve(1)}\n");
                Console.WriteLine($"Solution to part 2: {Day2.Solve(2)}\n");
                break;

            case 3:
                Console.WriteLine("\nSolving Day 3....");
                Console.WriteLine($"Solution to part 1: {Day3.SolvePart1()}\n");
                Console.WriteLine($"Solution to part 2: {Day3.SolvePart2()}\n");
                break;

            case 4:
                Console.WriteLine("\nSolving Day 4....");

                var day4 = new Day4();
                Console.WriteLine($"Solution to part 1: {day4.Solve(1)}\n");

                day4.RefreshInput();
                Console.WriteLine($"Solution to part 2: {day4.Solve(2)}\n");
                break;

            case 5:
                Console.WriteLine("\nSolving Day 5....");

                var day5 = new Day5();
                Console.WriteLine($"Solution to part 1: {day5.Solve()}\n");

                day5.RefreshInput();
                Console.WriteLine($"Solution to part 2: {day5.SolvePart2()}\n");
                break;

            case 6:
                Console.WriteLine("\nSolving Day 6....");

                var day6 = new Day6();
                Console.WriteLine($"Solution to part 1: {day6.Solve()}\n");

                day6.RefreshInput();
                Console.WriteLine($"Solution to part 2: {day6.SolvePart2()}\n");
                break;

            case 7:
                Console.WriteLine("\nSolving Day 7....");

                var day7 = new Day7();
                Console.WriteLine($"Solution to part 1: {day7.Solve()}\n");

                day7.RefreshInput();
                Console.WriteLine($"Solution to part 2: {day7.SolvePart2()}\n");
                break;

            case 99:
                Console.WriteLine("\nDoing custom fun stuff....");

                var quiz = new Quiz();
                Console.WriteLine($"Number of occurrences of \"make it so\" in all of TNG: {quiz.FindInTng("make it so")}");

                quiz = new Quiz();
                Console.WriteLine($"Number of occurrences of \"earl grey\" in all of TNG: {quiz.FindInTng("earl grey")}");

                quiz = new Quiz();
                Console.WriteLine($"Number of occurrences of \"earl grey hot\" in all of TNG: {quiz.FindInTng("earl grey hot")}");

                quiz = new Quiz();
                Console.WriteLine($"Number of occurrences of \"tea earl grey hot\" in all of TNG: {quiz.FindInTng("tea earl grey hot")}");

                quiz = new Quiz();
                Console.WriteLine($"Number of occurrences of \"shut up\" in all of TNG: {quiz.FindInTng("shut up")}");

                quiz = new Quiz();
                Console.WriteLine($"Number of occurrences of \"shut up wesley\" in all of TNG: {quiz.FindInTng("shut up wesley")}");

                break;

            default:
                break;
            }
        }
        public static void Solve(int day, int problemPart)
        {
            var puzzleInput = _loadFileInput(day);
            var solution    = 0;

            switch (day)
            {
            case 1:
                solution = Day1.Solve(puzzleInput, problemPart);
                break;

            case 2:
                solution = Day2.Solve(puzzleInput, problemPart);
                break;

            case 3:
                solution = Day3.Solve(puzzleInput);
                break;

            case 4:
                solution = Day4.Solve(puzzleInput);
                break;

            case 5:
                solution = Day5.Solve(puzzleInput);
                break;

            case 6:
                solution = Day6.Solve(puzzleInput);
                break;

            case 7:
                solution = Day7.Solve(puzzleInput);
                break;

            case 8:
                solution = Day8.Solve(puzzleInput);
                break;

            case 9:
                throw new NotImplementedException();
                break;

            case 10:
                throw new NotImplementedException();
                break;

            case 11:
                throw new NotImplementedException();
                break;

            case 12:
                throw new NotImplementedException();
                break;

            case 13:
                throw new NotImplementedException();
                break;

            case 14:
                throw new NotImplementedException();
                break;

            case 15:
                throw new NotImplementedException();
                break;

            case 16:
                throw new NotImplementedException();
                break;

            case 17:
                throw new NotImplementedException();
                break;

            case 18:
                throw new NotImplementedException();
                break;

            case 19:
                throw new NotImplementedException();
                break;

            case 20:
                throw new NotImplementedException();
                break;

            case 21:
                throw new NotImplementedException();
                break;

            case 22:
                throw new NotImplementedException();
                break;

            case 23:
                throw new NotImplementedException();
                break;

            case 24:
                throw new NotImplementedException();
                break;

            case 25:
                throw new NotImplementedException();
                break;

            default:
                Console.WriteLine("ERROR: Inavlid day");
                break;
            }

            Console.WriteLine($"Puzzle Solution: {solution}");
        }