Exemple #1
0
    public void Y2020_Day23_Play_Returns_Correct_Value_Part_1(int moves, int[] expected)
    {
        // Arrange
        int[] arrangement = { 3, 8, 9, 1, 2, 5, 4, 6, 7 };

        // Act
        LinkedList <int> actual = Day23.Play(arrangement, moves);

        // Assert
        actual.ShouldBe(expected);
    }
Exemple #2
0
    public void Y2020_Day23_Play_Returns_Correct_Value_Part_2()
    {
        // Arrange
        IEnumerable <int> arrangement = new[] { 3, 8, 9, 1, 2, 5, 4, 6, 7 }.Concat(Enumerable.Range(10, 999_991));

        // Act
        LinkedList <int> actual = Day23.Play(arrangement, moves: 10_000_000);

        LinkedListNode <int>?item1 = actual.Find(1);

        // Assert
        item1.ShouldNotBeNull();

        var next = item1.Next ?? actual.First;

        next.ShouldNotBeNull();
        next.Value.ShouldBe(934001);

        next = next.Next ?? actual.First;

        next.ShouldNotBeNull();
        next.Value.ShouldBe(159792);
    }