Beispiel #1
0
        public void Test2()
        {
            // check the reverse algorithm on the 10,007 deck with the input instructions
            var instructions = File.ReadAllLines(Path.Combine("..", "..", "..", "input", "day22.txt")).ToList();

            for (var p = 0; p < 10007; p++)
            {
                var final   = Day22.FindFinalPosition(instructions, p, 10007, 1);
                var initial = Day22.FindInitialPosition(instructions, final, 10007, 1);
                Assert.AreEqual(p, initial);
            }
        }
Beispiel #2
0
        public void Test1_1(int i, int[] expected)
        {
            var shuffler = new Day22.Shuffler(10);

            shuffler.Shuffle(Shuffles[i - 1]);
            var actual = shuffler.Deck;

            Assert.AreEqual(expected, actual);
            // using position-based calculation
            foreach (var p in expected.OrderBy(p => p))
            {
                Console.WriteLine();

                // verify FindFinalPosition (part 1 fast alternative)
                var expected2 = shuffler.IndexOf(p);
                var actual2   = Day22.FindFinalPosition(Shuffles[i - 1], p, expected.Length, 1L);
                Assert.AreEqual(expected2, actual2);

                // verify FindInitialPosition (part 2)
                var actual3 = Day22.FindInitialPosition(Shuffles[i - 1], actual2, expected.Length, 1L);
                Assert.AreEqual(p, actual3);
            }
        }