Beispiel #1
0
        public static void Part2()
        {
            var instructions = InputToInstructionSet(File.ReadAllLines("inputs/day8.txt"));
            var gameboy      = new SegaPlaytendo64SeriesX();

            for (int i = 0; i < instructions.Count; i++)
            {
                if (instructions[i].opcode == "jmp")
                {
                    instructions[i] = ("nop", instructions[i].argument);
                    (int accumulator, bool isInfiniteLoop) = gameboy.RunDay8Pt2Mode(instructions);
                    if (!isInfiniteLoop)
                    {
                        Console.WriteLine(accumulator);
                        return;
                    }
                    instructions[i] = ("jmp", instructions[i].argument);
                }
                else if (instructions[i].opcode == "nop")
                {
                    instructions[i] = ("jmp", instructions[i].argument);
                    (int accumulator, bool isInfiniteLoop) = gameboy.RunDay8Pt2Mode(instructions);
                    if (!isInfiniteLoop)
                    {
                        Console.WriteLine(accumulator);
                        return;
                    }
                    instructions[i] = ("nop", instructions[i].argument);
                }
            }
        }
Beispiel #2
0
        public static void Part1()
        {
            var instructions = InputToInstructionSet(File.ReadAllLines("inputs/day8.txt"));
            var gameboy      = new SegaPlaytendo64SeriesX();

            Console.WriteLine(gameboy.RunDay8Pt1Mode(instructions));
        }