Esempio n. 1
0
        private static (string part1, string part2) GetSolutions(RunDayOptions options)
        {
            var ctorType = new[] { typeof(string) };
            var ctor     = options.DayType.GetConstructor(ctorType);
            var part1    = ((Solution)ctor.Invoke(new object[] { $"day{options.DayString}" })).SolvePart1();
            var part2    = ((Solution)ctor.Invoke(new object[] { $"day{options.DayString}" })).SolvePart2();

            return(part1, part2);
        }
Esempio n. 2
0
        public static string Run(RunDayOptions options)
        {
            var(isValid, message) = options.Validate( );

            if (isValid)
            {
                var(part1, part2) = GetSolutions(options);

                message = options.Part switch
                {
                    1 => $"Year {options.Year}\nDay {options.DayString} Part 1: {part1}",
                    2 => $"Year {options.Year}\nDay {options.DayString} Part 2: {part2}",
                    _ => $"Year {options.Year}\nDay {options.DayString} Part 1: {part1} \nDay {options.DayString} Part 2: {part2}",
                };
            }

            Console.ForegroundColor = isValid ? ConsoleColor.Green : ConsoleColor.Red;
            return(message);
        }