示例#1
0
        public void CalculateLabelsAfterCupOneCorrectly(int moves, string expectedOrder)
        {
            var sut = new CupGame(SAMPLE_DATA_2);

            sut.Moves(moves);
            Assert.Equal(expectedOrder, sut.GetLabelsAfterCupOne());
        }
示例#2
0
        public void SolveFirstPuzzle()
        {
            var sut = new CupGame(PUZZLE_DATA);

            sut.Moves(100);
            Assert.Equal("97624853", sut.GetLabelsAfterCupOne());
        }
示例#3
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());
        }
示例#4
0
        public void RemoveCupsFromCircleCorrectly()
        {
            var sut = new CupGame(SAMPLE_DATA);

            sut.RemoveThreeCupsAfterCurrentCup();
            Assert.Collection(sut.GetCupsInOrder(),
                              c1 => Assert.Equal(3, c1),
                              c5 => Assert.Equal(5, c5));
        }
示例#5
0
        public void SolveSecondPuzzle_WhenUsingSampleData()
        {
            var sut = new CupGame(SAMPLE_DATA_2, 1000000);

            sut.Moves(10000000);
            Assert.Equal(934001, sut.FirstNumberAfterOne);
            Assert.Equal(159792, sut.SecondNumberAfterOne);
            Assert.Equal(149245887792UL, sut.MultiplyFirstAndSecondNumberAfterOne);
        }
        public string PartA()
        {
            CupGame game = new CupGame(Input);

            game.Play(100);
            string cupOrder = game.ListCupOrder();

            return(cupOrder);
        }
示例#7
0
        public void SolveSecondPuzzle()
        {
            var sut = new CupGame(PUZZLE_DATA, 1000000);

            sut.Moves(10000000);
            Assert.Equal(776819, sut.FirstNumberAfterOne);
            Assert.Equal(855595, sut.SecondNumberAfterOne);
            Assert.Equal(664642452305UL, sut.MultiplyFirstAndSecondNumberAfterOne);
        }
示例#8
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());
        }
示例#9
0
        public void CupGame_Play(int moves, string expected)
        {
            var input = "389125467";
            var sut   = new CupGame(input);

            sut.Play(moves);
            var result = sut.ListCupOrder();

            Assert.Equal(expected, result);
        }
        public string PartB()
        {
            CupGame game = new CupGame(Input, 1000000);

            game.Play(10000000);
            var  one         = game.GetCup(1);
            long right       = one.Next.Value;
            long doubleRight = one.Next.Next.Value;

            return((right * doubleRight).ToString());
        }
示例#11
0
        public void LoadCupOrderFromDataCorrectly()
        {
            var sut = new CupGame(SAMPLE_DATA);

            Assert.Collection(sut.GetCupsInOrder(),
                              c1 => Assert.Equal(3, c1),
                              c2 => Assert.Equal(2, c2),
                              c3 => Assert.Equal(4, c3),
                              c4 => Assert.Equal(1, c4),
                              c5 => Assert.Equal(5, c5));
        }
示例#12
0
        public void Part1LongTest()
        {
            // Given
            var game = new CupGame("389125467".Select(c => int.Parse(c.ToString())).ToList());

            // When
            for (var i = 0; i < 100; i++)
            {
                game.Move();
            }

            // Then
            Assert.Equal("67384529", game.ToString(1)[1..]);
示例#13
0
        public void RemoveCupsFromCircleCorrectly_WhenUsingSampleData()
        {
            var sut = new CupGame(SAMPLE_DATA_2);

            sut.RemoveThreeCupsAfterCurrentCup();

            Assert.Collection(sut.GetCupsInOrder(),
                              c1 => Assert.Equal(3, c1),
                              c2 => Assert.Equal(2, c2),
                              c3 => Assert.Equal(5, c3),
                              c4 => Assert.Equal(4, c4),
                              c5 => Assert.Equal(6, c5),
                              c6 => Assert.Equal(7, c6));
        }
示例#14
0
        public void MoveRemovedCupsToNewPositionCorrectly()
        {
            var sut = new CupGame(SAMPLE_DATA);

            sut.RemoveThreeCupsAfterCurrentCup();
            sut.SelectDestinationCup();

            sut.MoveSelectedCupsAfterDestinationCup();
            Assert.Collection(sut.GetCupsInOrder(),
                              c1 => Assert.Equal(3, c1),
                              c2 => Assert.Equal(5, c2),
                              c3 => Assert.Equal(2, c3),
                              c4 => Assert.Equal(4, c4),
                              c5 => Assert.Equal(1, c5));
        }
示例#15
0
        public void ExecuteTenMovesCorrectly()
        {
            var sut = new CupGame(SAMPLE_DATA_2);

            sut.Moves(10);
            Assert.Collection(sut.GetCupsInOrder(),
                              c1 => Assert.Equal(5, c1),
                              c2 => Assert.Equal(8, c2),
                              c3 => Assert.Equal(3, c3),
                              c4 => Assert.Equal(7, c4),
                              c5 => Assert.Equal(4, c5),
                              c6 => Assert.Equal(1, c6),
                              c7 => Assert.Equal(9, c7),
                              c8 => Assert.Equal(2, c8),
                              c9 => Assert.Equal(6, c9));
        }
示例#16
0
        public void Part1Test()
        {
            // Given
            var game = new CupGame("389125467".Select(c => int.Parse(c.ToString())).ToList());

            Assert.Equal("389125467", game.ToString(3));

            game.Move();
            Assert.Equal("328915467", game.ToString(3));

            game.Move();
            Assert.Equal("325467891", game.ToString(3));

            game.Move();
            Assert.Equal("725891346", game.ToString(7));

            game.Move();
            Assert.Equal("325846791", game.ToString(3));

            game.Move();
            Assert.Equal("925841367", game.ToString(9));

            game.Move();
            Assert.Equal("725841936", game.ToString(7));

            game.Move();
            Assert.Equal("836741925", game.ToString(8));

            game.Move();
            Assert.Equal("741583926", game.ToString(7));

            game.Move();
            Assert.Equal("574183926", game.ToString(5));

            game.Move();
            Assert.Equal("583741926", game.ToString(5));
        }
示例#17
0
        public void CreateTenMillionCupsCorrectly()
        {
            var sut = new CupGame(SAMPLE_DATA_2, 1000000);

            Assert.Equal(1000000, sut.GetCupsInOrder().Count);
        }
示例#18
0
 // Start is called before the first frame update
 void Start()
 {
     cg = GameObject.FindGameObjectWithTag("Finish").GetComponent <CupGame>();
 }
示例#19
0
 // Start is called before the first frame update
 void Start()
 {
     cg = GameObject.FindGameObjectWithTag("Finish").GetComponent <CupGame>();
     sm = GameObject.FindGameObjectWithTag("Finish").GetComponent <ScoreManager>();
 }