Exemplo n.º 1
0
        private static long PuzzleOne()
        {
            IntcodeComputerV2 ic = new IntcodeComputerV2("Day-02-input.txt");

            ic.Ints[1] = 12;
            ic.Ints[2] = 2;
            ic.CalculateOutput();

            return ic.Ints[0];
        }
Exemplo n.º 2
0
        public static void Puzzle()
        {
            IntcodeComputerV2 ic = new IntcodeComputerV2("Day-05-input.txt");

            Console.WriteLine($"Puzzle one answer: {ic.CalculateOutput(1)}"); // Answer is incorrect after changes in Day 7. Is it a bug or mistake in AoC?

            IntcodeComputerV2 ic2 = new IntcodeComputerV2("Day-05-input.txt");

            Console.WriteLine($"Puzzle two answer: {ic2.CalculateOutput(5)}");
        }
Exemplo n.º 3
0
        private static long PuzzleTwo()
        {
            const int minVal = 0;
            const int maxVal = 99;
            const int outputSought = 19690720;

            for (int noun = minVal; noun <= maxVal; ++noun)
            {
                for (int verb = minVal; verb <= maxVal; ++verb)
                {
                    IntcodeComputerV2 ic = new IntcodeComputerV2("Day-02-input.txt");
                    ic.Ints[1] = noun;
                    ic.Ints[2] = verb;
                    ic.CalculateOutput();

                    if (ic.Ints[0] == outputSought)
                        return (noun * 100 + verb);
                }
            }

            return -1;
        }
Exemplo n.º 4
0
        public static void PuzzleOne()
        {
            int[] phaseValues  = new int[] { 0, 1, 2, 3, 4 };
            var   combinations = GetPermutations(phaseValues, amplifiersCount);

            long maxVal = long.MinValue;

            foreach (var inputArray in combinations)
            {
                int[] array = inputArray.ToArray();
                long  input = 0;

                for (int i = 0; i < amplifiersCount; ++i)
                {
                    IntcodeComputerV2 ic = new IntcodeComputerV2(inputFilename);
                    input  = ic.CalculateOutput(array[i], input);
                    maxVal = input > maxVal ? input : maxVal;
                }
            }

            Console.WriteLine($"Puzzle one answer: {maxVal}");
        }
Exemplo n.º 5
0
        public static void PuzzleOne()
        {
            IntcodeComputerV2 ic = new IntcodeComputerV2(inputFilename);

            Console.WriteLine($"Puzzle one answer: {ic.CalculateOutput(1)}");
        }