예제 #1
0
        public void Day22Part1_TestSolutionByFollowingIndexInReverse()
        {
            string[] cmds = DayDataUtilities.ReadLinesFromFile("day22.txt");
            Assert.NotNull(cmds);
            Assert.Equal(100, cmds.Length);
            SlamShufflerIndex sut = new SlamShufflerIndex(10007, 3324);

            for (int i = cmds.Length - 1; i >= 0; i--)
            {
                sut.ShuffleCommandReverse(cmds[i]);
            }
            long actual = sut.TrackedIndex;

            Assert.Equal(2019, actual);
        }
예제 #2
0
        public void Day22Part2_TestSolutionJustOnce()
        {
            // both are primes, 99% sure.
            long deckSize     = 119315717514047;
            long shuffleTimes = 101741582076661;

            string[] cmds = DayDataUtilities.ReadLinesFromFile("day22.txt");
            Assert.NotNull(cmds);
            Assert.Equal(100, cmds.Length);

            SlamShufflerIndex sut = new SlamShufflerIndex(deckSize, 2020);

            for (int i = cmds.Length - 1; i >= 0; i--)
            {
                sut.ShuffleCommandReverse(cmds[i]);
            }

            long actual = sut.TrackedIndex;

            Assert.Equal(27321782275977, actual);
        }