Beispiel #1
0
        public void Example22()
        {
            ElfGame game = new ElfGame();

            int result = game.GetNthNumber2(new List <int> {
                1, 3, 2
            }, 30000000);

            Assert.AreEqual(2578, result);
        }
Beispiel #2
0
        public void Example6()
        {
            ElfGame game = new ElfGame();

            game.AddNumber(3);
            game.AddNumber(2);
            game.AddNumber(1);

            int result = game.GetNthNumber(2020);

            Assert.AreEqual(438, result);
        }
Beispiel #3
0
        public static int Problem2()
        {
            List <int> input = File.ReadAllText("Data/Day15.txt").Split(",").Select(i => i.ToInt()).ToList();

            ElfGame game = new ElfGame();

            int result = game.GetNthNumber2(input, 30000000);

            Console.WriteLine(result);

            return(result);
        }
Beispiel #4
0
        public void Example27()
        {
            ElfGame game = new ElfGame();

            game.AddNumber(3);
            game.AddNumber(1);
            game.AddNumber(2);

            int result = game.GetNthNumber2(new List <int> {
                3, 1, 2
            }, 30000000);

            Assert.AreEqual(362, result);
        }
Beispiel #5
0
        public void Example25()
        {
            ElfGame game = new ElfGame();

            game.AddNumber(2);
            game.AddNumber(3);
            game.AddNumber(1);

            int result = game.GetNthNumber2(new List <int> {
                2, 3, 1
            }, 30000000);

            Assert.AreEqual(6895259, result);
        }
Beispiel #6
0
        public void Example24()
        {
            ElfGame game = new ElfGame();

            game.AddNumber(1);
            game.AddNumber(2);
            game.AddNumber(3);

            int result = game.GetNthNumber2(new List <int> {
                1, 2, 3
            }, 30000000);

            Assert.AreEqual(261214, result);
        }
Beispiel #7
0
        public void Example21()
        {
            ElfGame    game    = new ElfGame();
            List <int> numbers = new List <int> {
                0, 3, 6
            };

            //int result = game.GetNthNumber(30000000);
            int result = game.GetNthNumber2(new List <int> {
                0, 3, 6
            }, 30000000);

            Assert.AreEqual(175594, result);
        }
Beispiel #8
0
        public static int Problem1()
        {
            List <int> input = File.ReadAllText("Data/Day15.txt").Split(",").Select(i => i.ToInt()).ToList();


            ElfGame game = new ElfGame();

            foreach (int number in input)
            {
                game.AddNumber(number);
            }

            int result = game.GetNthNumber(2020);

            Console.WriteLine(result);


            return(result);
        }