Exemple #1
0
        static void Main(string[] args)
        {
            Console.Write("..:: AdventOfCode 2020 ::..\n");

#if (DEBUG == false)
            var leaderboards = new[] { Leaderboard.PrintLeaderboard("142643"), Leaderboard.PrintLeaderboard("606817") };
#endif

            var days = typeof(Program).Assembly.GetTypes()
                       .Where(t => t.Name.StartsWith("Day", StringComparison.InvariantCultureIgnoreCase)).OrderBy(d => d.Name)
                       .Select(d => d.GetConstructor(Type.EmptyTypes).Invoke(null) as AbstractDay)
                       .ToList();

#if (DEBUG == false)
            var runLongParts = false;
            if (days.Any(d => d.IsLongRunning1 || d.IsLongRunning2))
            {
                var ans = "";
                do
                {
                    Console.Write("Some parts may run a long time (more than 10s). Run them? [y/N]: ");
                    var input = Console.ReadLine();
                    if (string.IsNullOrWhiteSpace(input))
                    {
                        ans = "n";
                    }
                    else
                    {
                        ans = char.ToLower(input[0]).ToString();
                    }
                } while (ans != "y" && ans != "n");
                if (ans == "y")
                {
                    runLongParts = true;
                }
            }
#endif

            var start = DateTime.Now;

            days.Take(days.Count - TAKE_SEPERATE).AsParallel().ForAll(d =>
            {
                d.ExecDay(
#if DEBUG
                    true
#else
                    false, !runLongParts
#endif
                    );
            });

            foreach (var d in days.Skip(days.Count - TAKE_SEPERATE))
            {
                d.ExecDay();
            }

            var duration = DateTime.Now - start;
            var hours    = (int)duration.TotalHours;
            var timeUsed = $"{hours:D2}:{duration:mm\\:ss\\.fff}";

            foreach (var d in days)
            {
                Console.Write(d);
            }
            Console.WriteLine($"\n\n*** Time to compute in total: {timeUsed} ***");

#if (DEBUG == false)
            leaderboards.ForEach(t => Console.WriteLine(t.Result));
#else
            Console.WriteLine("\nLeaderboard is only displayed in Release mode to prevent distractions during solving");
#endif
        }
        public static void Main(string[] args)
        {
            Logger.ShowDebug = false;

            Leaderboard.Start();

            Day01.StartA();
            Day01.StartB();

            Day02.StartA();
            Day02.StartB();

            Day03.StartA();
            Day03.StartB();

            Day04.StartA();
            Day04.StartB();

            Day05.StartA();
            Day05.StartB();

            Day06.StartA();
            Day06.StartB();

            Day07.StartA();
            Day07.StartB();

            Day08.StartA();
            Day08.StartB();

            Day09.StartA();
            Day09.StartB();

            Day10.StartA();
            Day10.StartB();

            Day11.StartA();
            Day11.StartB();

            Day12.StartA();
            Day12.StartB();

            Day13.StartA();
            Day13.StartB();
            Day13.StartB2();
            Day13.StartB3();

            Day14.StartA();
            Day14.StartB();

            Day15.StartA();
            Day15.StartB();

            Day16.StartA();
            Day16.StartB();

            Day17.StartA();
            Day17.StartB();

            Day18.StartA();
            Day18.StartB();

            Day19.StartA();
            Day19.StartB();

            Day20.StartA();
            Day20.StartB();

            Day21.StartA();
            Day21.StartB();

            Day22.StartA();
            Day22.StartB();

            Day23.StartA();
            Day23.StartB();

            Day24.StartA();
            Day24.StartB();

            Day25.StartA();

            Logger.ShowDebug = true;

            Console.ReadKey();
        }