Beispiel #1
0
        public void PlayCrabCupsTest()
        {
            var testData = new List <Tuple <IList <int>, int, int, IList <int> > >()
            {
                new Tuple <IList <int>, int, int, IList <int> >(
                    new List <int>()
                {
                    3, 8, 9, 1, 2, 5, 4, 6, 7
                },
                    3,
                    10,
                    new List <int>()
                {
                    5, 8, 3, 7, 4, 1, 9, 2, 6
                }),
                new Tuple <IList <int>, int, int, IList <int> >(
                    new List <int>()
                {
                    3, 8, 9, 1, 2, 5, 4, 6, 7
                },
                    3,
                    100,
                    new List <int>()
                {
                    1, 6, 7, 3, 8, 4, 5, 2, 9
                })
            };

            foreach (var testExample in testData)
            {
                var actual        = CrabCupHelper.PlayCrabCups(testExample.Item1, testExample.Item2, testExample.Item3);
                var areEquivalent = CrabCupHelper.GetAreEquivalent(testExample.Item4, actual);
                Assert.True(areEquivalent);
            }
        }
Beispiel #2
0
        private static string GetDay23Part1()
        {
            var startingNumbers = GetDay23Input();
            var finalState      = CrabCupHelper.PlayCrabCups(startingNumbers, 3, 100);
            var result          = CrabCupHelper.GetCanonicalCrabCupString(finalState);

            return(result);
        }
Beispiel #3
0
        private static long GetDay23Part2()
        {
            var initialStartingNumbers = GetDay23Input();
            var startingNumbers        = CrabCupHelper.GetPart2StartingNumbers(initialStartingNumbers);
            var finalState             = CrabCupHelper.PlayCrabCups(startingNumbers, 3, 10000000);
            var oneIndex    = finalState.IndexOf(1);
            var label1Index = (oneIndex + 1) % 1000000;
            var label2Index = (oneIndex + 2) % 1000000;
            var label1      = finalState[label1Index];
            var label2      = finalState[label2Index];

            return((long)label1 * (long)label2);
        }