Example #1
0
        public void Day22Part1_Example04()
        {
            int[]    expectedCards = new int[] { 9, 2, 5, 8, 1, 4, 7, 0, 3, 6 };
            string[] cmds          = new string[]
            {
                "deal into new stack",
                "cut -2",
                "deal with increment 7",
                "cut 8",
                "cut -4",
                "deal with increment 7",
                "cut 3",
                "deal with increment 9",
                "deal with increment 3",
                "cut -1"
            };
            SlamShuffler sut = new SlamShuffler(10);

            foreach (string cmd in cmds)
            {
                sut.ShuffleCommand(cmd);
            }

            for (int i = 0; i < 10; i++)
            {
                Assert.Equal(expectedCards[i], sut.DeckOfCards[i]);
            }
        }
Example #2
0
        public void Day22Part1_TestSolution()
        {
            string[] cmds = DayDataUtilities.ReadLinesFromFile("day22.txt");
            Assert.NotNull(cmds);
            Assert.Equal(100, cmds.Length);
            SlamShuffler sut = new SlamShuffler(10007);

            foreach (string cmd in cmds)
            {
                sut.ShuffleCommand(cmd);
            }

            int actual = sut.DeckOfCards.FindIndex(c => c == 2019);

            Assert.Equal(3324, actual);
            //sut.DumpDeckOfCards(@"c:\work\cards.csv");
        }
Example #3
0
        public void Day22Part1_Example03()
        {
            int[]    expectedCards = new int[] { 6, 3, 0, 7, 4, 1, 8, 5, 2, 9 };
            string[] cmds          = new string[]
            {
                "deal with increment 7",
                "deal with increment 9",
                "cut -2"
            };
            SlamShuffler sut = new SlamShuffler(10);

            foreach (string cmd in cmds)
            {
                sut.ShuffleCommand(cmd);
            }

            for (int i = 0; i < 10; i++)
            {
                Assert.Equal(expectedCards[i], sut.DeckOfCards[i]);
            }
        }