예제 #1
0
        public void TestInfiniteGame()
        {
            var input = @"Player 1:|43|19||Player 2:|2|29|14".Replace("|", Environment.NewLine); var(player1, player2) = DeckParser.Parse(input);
            var game  = new RecursiveCombat(new List <Player> {
                player1, player2
            });

            while (!game.Complete())
            {
                game.PlayRound();
            }

            Assert.Equal(78, player2.CalculateScore());
        }
예제 #2
0
        public void ScoreCalcTestPuzzle2()
        {
            var input = @"Player 1:|9|2|6|3|1||Player 2:|5|8|4|7|10".Replace("|", Environment.NewLine);

            var(player1, player2) = DeckParser.Parse(input);
            var game = new RecursiveCombat(new List <Player> {
                player1, player2
            });

            while (!game.Complete())
            {
                game.PlayRound();
            }

            Assert.Equal(291, player2.CalculateScore());
        }
예제 #3
0
        public void Puzzle2()
        {
            var input = new FileReader()
                        .GetResource("AdventOfCode2020.Tests.Day22.PuzzleInput.txt");

            var(player1, player2) = DeckParser.Parse(input);
            var game = new RecursiveCombat(new List <Player> {
                player1, player2
            });

            while (!game.Complete())
            {
                game.PlayRound();
            }

            Assert.Equal(1800, game.Rounds);

            Assert.Equal(9833, game.GetWinner().CalculateScore());
        }