Beispiel #1
0
        private static Scores GenerateScores(int RecipeAfter)
        {
            Scores scores = new Scores();
            Elf    elf1   = new Elf(scores, 3);
            Elf    elf2   = new Elf(scores, 7);

            for (int rounds = 2; scores.NumberOfRecipes < RecipeAfter + 10; rounds++)
            {
                var        sum    = elf1.GetCurrentScore() + elf2.GetCurrentScore();
                List <int> values = sum.ToString().ToCharArray().Select(x => Int32.Parse(x.ToString())).ToList();
                scores.InsertRecipe(values);
                elf1.Move();
                elf2.Move();
            }

            return(scores);
        }
Beispiel #2
0
        // Brute force - tar tid
        private static void Part2_GetRecipesAfterScore(int AfterScore)
        {
            Scores scores = GenerateScores(AfterScore * 200);

            Console.WriteLine(scores.GetNumberOfRecipes(AfterScore));
        }
Beispiel #3
0
        private static void Part1_GetScoreAfterRecipes(int RecipeAfter)
        {
            Scores scores = GenerateScores(RecipeAfter);

            Console.WriteLine(scores.GetScoreOfTenRecipes(RecipeAfter));
        }