Exemplo n.º 1
0
        static void Main(string[] args)
        {
            string[]        input           = File.ReadAllLines("./input.txt");
            JumpInstruction jumpInstruction = new JumpInstruction(input);

            Console.WriteLine(jumpInstruction.CalcLargest());   // Part 1
            Console.WriteLine(jumpInstruction.LargestHeld);     // Part 2
        }
Exemplo n.º 2
0
        public static IEnumerable <IList <Instruction> > GetModifiedInstructionSets(IList <Instruction> instructions)
        {
            for (var instructionCounter = 0; instructionCounter < instructions.Count; instructionCounter++)
            {
                var copyOfInstructions = new List <Instruction>(instructions);
                var instruction        = instructions[instructionCounter];
                switch (instruction)
                {
                case NoOpInstruction noOpInstruction:
                    copyOfInstructions[instructionCounter] = new JumpInstruction(noOpInstruction.Value);
                    break;

                case JumpInstruction jumpInstruction:
                    copyOfInstructions[instructionCounter] = new NoOpInstruction(jumpInstruction.Value);
                    break;

                case AccumulatorInstruction accumulatorInstruction:
                    break;
                }

                yield return(copyOfInstructions);
            }
        }