示例#1
0
文件: Solution.cs 项目: nerddtvg/aoc
        protected override string SolvePartTwo()
        {
            // Load the initial game
            game = new CupGame(Input, 1000000);

            // Get a stopwatch ready!
            var sw = new System.Diagnostics.Stopwatch();

            Console.WriteLine($"Part 2 Started");

            Console.WriteLine($"Part 2 Loading: {new TimeSpan(sw.ElapsedTicks)}");

            // Now play the game ten million (10000000) times
            sw.Reset();
            sw.Start();
            for (int i = 0; i < 10000000; i++)
            {
                game.playRound();

                // Every 100,000 print time
                if (i > 0 && i % 100000 == 0)
                {
                    Console.WriteLine($"Part 2 Round {i.ToString("N0")}: {new TimeSpan(sw.ElapsedTicks)}");
                }
            }
            sw.Stop();

            Console.WriteLine($"Part 2 Calculation: {new TimeSpan(sw.ElapsedTicks)}");

            Console.WriteLine($"Part 2 Complete");

            // Now we only want the two cups immediately clockwise of cup 1
            return(game.getCupsAfter1().ToString());
        }
示例#2
0
文件: Solution.cs 项目: nerddtvg/aoc
        protected override string SolvePartOne()
        {
            game = new CupGame(Input);
            for (int i = 0; i < 100; i++)
            {
                game.playRound();
            }

            return(game.ToString());
        }