示例#1
0
        public void Part2()
        {
            var game = new MarbleGame(_players, _lastMarble * 100);

            game.Play();
            Assert.Equal((ulong)3350093681, game.LeadingPlayer.score);
        }
示例#2
0
        public void GameShouldPlay(int players, int lastMarble, ulong expectedScore)
        {
            var game = new MarbleGame(players, lastMarble);

            game.Play();
            Assert.Equal(expectedScore, game.LeadingPlayer.score);
        }
示例#3
0
        public void Part1()
        {
            var game = new MarbleGame(_players, _lastMarble);

            game.Play();
            Assert.Equal((ulong)404611, game.LeadingPlayer.score);
        }
示例#4
0
    public long Solve()
    {
        marbleGame.Play();
        long maxPoints = marbleGame.MaxScore;

        Console.WriteLine(maxPoints);
        return(maxPoints);
    }
示例#5
0
        public void Puzzle1Examples_FindsCorrectMaxScore(int playerCount, int maxMarbleValue, ulong expectedMaxScore)
        {
            var game = new MarbleGame(playerCount, maxMarbleValue);

            game.Play();

            game.Players.Max(x => x.Score).Should().Be(expectedMaxScore);
        }
示例#6
0
        public void Puzzle2_FindMaxScoreWith100xTheMaxMarbleValue()
        {
            var game = new MarbleGame(Input.Day09.Players, Input.Day09.LastMarble * 100);

            game.Play();

            game.Players.Max(x => x.Score).Should().Be(3243916887);
        }
示例#7
0
        public void Puzzle1_FindMaxScore()
        {
            var game = new MarbleGame(Input.Day09.Players, Input.Day09.LastMarble);

            game.Play();

            game.Players.Max(x => x.Score).Should().Be(404502);
        }
示例#8
0
        public void Puzzle1Example_FindsCorrectPlayerAndTopScore()
        {
            const int players        = 9;
            const int maxMarbleValue = 25;
            var       game           = new MarbleGame(players, maxMarbleValue);

            game.Play();

            game.Current.Value.Should().Be(25);
            var maxPlayer = game.Players.MaxBy(x => x.Score).Single();

            maxPlayer.Id.Should().Be(5);
            maxPlayer.Score.Should().Be(32);
        }
示例#9
0
        public void Puzzle1Example_StepsCorrectly()
        {
            const int players        = 9;
            const int maxMarbleValue = 25;
            var       game           = new MarbleGame(players, maxMarbleValue);

            game.Players.Should().HaveCount(9).And.BeInAscendingOrder(x => x.Id);
            game.Players.First().Id.Should().Be(1);

            Output.WriteLine($"\n[-] {game}");
            foreach (var player in game.Players)
            {
                game.Play(player);
                Output.WriteLine($"[{player.Id}] {game}");
            }

            game.Current.Value.Should().Be(9);
        }
        public void PlayTest()
        {
            // the size of the board (2 ≤ N ≤ 40)
            byte N = 4;
            // the number of marbles (M > 0)
            byte M = 3;
            // the number of walls
            byte W = 1;

            // locations of the marbles
            Marble[] marbles = new Marble[] { new Marble(1, 0, 1), new Marble(2, 1, 0), new Marble(3, 1, 2) };

            // locations of the holes
            Hole[] holes = new Hole[] { new Hole(1, 2, 3), new Hole(2, 2, 1), new Hole(3, 3, 2) };

            WallLocation[] walls = new WallLocation[] { new WallLocation(new Location(1, 1), new Location(1, 2)) };

            MarbleGame game = new MarbleGame();

            var result = game.Play(N, walls, holes, marbles);

            Assert.Fail();
        }