static LineOfCode[] CopyProgram(LineOfCode[] code) { var copy = new LineOfCode[code.Length]; Array.Copy(code, copy, code.Length); return(copy); }
static LineOfCode SwapInstruction(LineOfCode lineOfCode) { return(new LineOfCode { LineNumber = lineOfCode.LineNumber, Value = lineOfCode.Value, Instruction = lineOfCode.Instruction.Equals("nop") ? "jmp" : "nop" }); }
static void GetInputs() { var lines = File.ReadAllLines("input.txt"); Console.WriteLine($"Read {lines.Length} inputs"); _inputs = new LineOfCode[lines.Length]; for (var i = 0; i < lines.Length; i++) { var line = lines[i]; var tokens = line.Split(new[] { " ", "+" }, StringSplitOptions.RemoveEmptyEntries); _inputs[i] = new LineOfCode { LineNumber = i, Instruction = tokens[0], Value = int.Parse(tokens[1]) }; } }