コード例 #1
0
        static void Main(string[] args)
        {
            IPuzzle       p;
            List <string> input = new();

            int puzzleNumber = int.Parse(args[0]);

            switch (puzzleNumber)
            {
            case 1:
                p = new Puzzle1();
                break;

            case 2:
                p = new Puzzle2();
                break;

            case 3:
                p = new Puzzle3();
                break;

            case 4:
                p = new Puzzle4();
                break;

            default:
                throw new ArgumentException("Invalid puzzle number");
            }

            Console.WriteLine("Paste puzzle input now, with a blank line to finish:");

            string consoleInput;

            while (true)
            {
                consoleInput = Console.ReadLine();
                if (string.IsNullOrEmpty(consoleInput))
                {
                    break;
                }

                input.Add(consoleInput);
            }

            p.Input(input);
            Console.WriteLine($"Puzzle solved: {p.Run()}");
        }
コード例 #2
0
        static void Main(string[] args)
        {
            Console.WriteLine("Which puzzle would you like to run?");
            string puzzle = Console.ReadLine();

            switch (puzzle)
            {
            case "1":
                Puzzle1.Run();
                break;

            case "2a":
                Puzzle2.Run(1);
                break;

            case "2b":
                Puzzle2.Run(2);
                break;

            case "3a":
                Puzzle3.Run(1);
                break;

            case "4a":
                Puzzle4.Run(1);
                break;

            case "4b":
                Puzzle4.Run(2);
                break;

            case "5a":
                Puzzle5.Run(1);
                break;

            case "5b":
                Puzzle5.Run(2);
                break;

            default:
                Console.WriteLine("Puzzle not found");
                break;
            }
        }