コード例 #1
0
ファイル: Day1814.cs プロジェクト: andi0b/adventofcode
        public override object SolvePart2(string input)
        {
            var recipeBoard = new RecipeBoard();

            var length      = input.Length;
            var inputNumber = int.Parse(input);

            while (true)
            {
                recipeBoard.Step();

                if (recipeBoard.Count - 1 < length)
                {
                    continue;
                }

                if (recipeBoard.GetScores(recipeBoard.Count - length, length) == inputNumber)
                {
                    return(recipeBoard.Count - length);
                }
                if (recipeBoard.GetScores(recipeBoard.Count - length - 1, length) == inputNumber)
                {
                    return(recipeBoard.Count - length - 1);
                }
            }
        }
コード例 #2
0
ファイル: Day1814.cs プロジェクト: andi0b/adventofcode
        public override object SolvePart1(int input)
        {
            var recipeBoard = new RecipeBoard();

            for (var i = 0; i < input + 10; i++)
            {
                recipeBoard.Step();
            }

            return(recipeBoard.GetScores(input, 10).ToString("D10"));
        }